Fixes RDF export of subobjects

Partial integration of the patch https://gerrit.wikimedia.org/r/#/c/70047/4
from Dbeeson
Best to put this into its own PR, write a test and merge so the complexity of this PR is decreased.