Return dict instead of building on a document

This to be able to use the #build_resources() method when using linked
documents.
Rename the relations test
Add support for compound documents