I need to create RDF that looks like this:
<rdf:Description rdf:about='uri1'>
<namespace:level1>
<rdf:Description>
<namespace:blankNode rdf:resource='uri2'/>
<namespace:text></namespace:text>
</rdf:Description>
</namespace:level1>
</rdf:Description>
<rdf:Description rdf:about="uri2">
some properties here
</rdf:Description>
As you can see, there are nested structures, as well as blank nodes. (I don't know if that's the exact terminology for the "blankNode" property in my structure.) If I use
model.write(System.out, "RDF/XML-ABBREV");
then even the blank node is nested, which I don't want. Is there any way to get this kind of structure using Jena? Or is there any other library for Java that can handle this better?
I think you're going at this the wrong way.
Nesting is a concept that only makes sense when talking about trees. But RDF is not about trees, it's about triples. Forget for a while about the structure of the XML, and think about the triples that are encoded in the XML. I find model.write(System.out, "N-TRIPLES");
most useful for that.
You first need to understand what triples you want your RDF/XML file to express. As long as it expresses the right triples, it doesn't matter whether the one node is written nested inside the other or what order things appear in. These are purely “cosmetic” questions, like indentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With