Search code examples
javardfsemantic-webjena

Create RDF with nested nodes in Apache Jena


A similiar question was asked already here How to get nested RDF/XML from Jena?.

I didn't find the answer helpful: As the author I want to map something like this:

<address>
   <street>...</street>
   <postcode>...</postcode>
   .
   .
   .
</adress>

The answer was given that in RDF you have to think about triples, but doesn't apply that here?

  • (Address, has street, ...)
  • (Address, has postcode, ...)
  • (Person, has address, ...)

Another reason why I am asking, I have used Jena Bean to generate RDF out of my Java Class Model and the result was also a nested structure. Now I want to do the same with Apache Jena and I can't get it figured out, no hint in the document, I tried it out, no idea so far.


Solution

  • Have you tried the official tutorial? It's shown how to do what you're asking about.

    They're using a predefined dictionary for the VCard namespace, which comes with Jena jars but it's easy to define your own dictionary just after a glance at the predefined ones.

    Here's the tutorial http://jena.apache.org/tutorials/rdf_api.html#ch-Introduction

    You should also check out the RDF Validator: http://www.w3.org/RDF/Validator/ It allows you to validate your RDF (who would've guessed) and also to visualize it as a graph. It really helps you see and realize the mistakes you make while creating an ontology. It saved me lots of fruitless efforts and frustration.