Fixes RDF export of subobjects

Partial integration of the patch https://gerrit.wikimedia.org/r/#/c/70047/4
from Dbeeson
Moved to https://github.com/SemanticMediaWiki/SemanticMediaWiki/pull/345

I need some feedback before any tests are written as mentioned in the commit message.