2

I am trying to find out the best way of converting an RDF/XML file into Java Objects. So far I have been struggling to find an easy solution...perhaps because I am new to RDF/XML and Semantic Web Programming I am just missing it.

I have an XSD file as well as an OWL (containing RDFS) file. I have played with Jena, Jastor, and RDFReactor to no positive effect. Perhaps I am just not doing it right.

Any help would be greatly appreciated to find the best approach to do this.

note I can post snippets of whatever you may think you need to see to help me solve this problem.

flag

3 Answers

3

Jena itself gives you API access to the data and you can create wrapper objects using the Enhanced Node machinery, but it doesn't have automatic mapping to POJOs.

I've been impressed by presentations on JenaBeans and that seems to be a more actively supported project that Jastor at this point. Though it's design centre is more about mapping Java objects to RDF so may not be so much use the other way round.

The combination of XSD and OWL was never standardized (at least until the new OWL 2 specs which embed XSD-like datatyping in OWL). There were conventions inherited from DAML but it wouldn't be surprising if the OWL-to-java tools had problems handling the link from a user defined datatype URI to the corresponding XSD.

link|flag
2

Sommer has a good reputation for POJO to RDF mapping.

It uses annotations to map the POJO. One of the examples on that page looks like:

@rdf(foaf + "Agent")
public class Agent {
   public static final String foaf = "http://xmlns.com/foaf/0.1/";

   //field declarations
   @rdf(foaf + "mbox") private Collection<URI> mboxes;
   @rdf(foaf + "mbox_sha1sum") private Collection<String> mbox_sha1sums;

   @rdf(foaf + "jabberID") private String jabberId;
   @rdf(foaf + "aimChatID") private String aimChatId;

   ...

}
link|flag
1

Sommer is good and I like the annotations approach, but the new kid on the block for RDF/Java serialization that looks very good is Empire, from the same people that made the Pellet reasoner (Clark & Parsia). It uses annotations, plus they are the standard JPA annotations as it's a JPA implementation for semantic web data. The link below is to a blog tutorial on using Empire.

http://clarkparsia.com/weblog/2010/05/07/using-empire/

An example:

   @RdfProperty("dc:title")
   private String title;

   @RdfProperty("dc:publisher")
   private String publisher;

   @RdfProperty("dc:issued")
   private Date issued;

   @RdfProperty("frbr:embodiment")
   @OneToMany(fetch = FetchType.LAZY,
       cascade = {CascadeType.PERSIST, CascadeType.MERGE})
   private Collection<Manifestation> mEmbodiments = new HashSet<Manifestation>();
link|flag

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.