Dienstag, 22. Mai 2012

How to generate Java files from OWL-files in Jena - Extension

This is an extension of Andra Waagmester's "How to generate Java files from OWL-files in Jena."

For some files, like the PAV OWL-file, you will just get the header, but none of the predicates or classes. Here is the reason why:

Schemagen is picking a namespace for your ontology, and is defaulting to the value of the xmlns-attribute:

<rdf:RDF xmlns="&pav;2.0/"
     xml:base="&pav;2.0/"

Hence http://purl.org/pav/2.0/

However, all of their declarations are actually in a non-versioned namespace:
xmlns:pav="http://purl.org/pav/"

So it is necessary to tell schemagen to use the right namespace with -a, or change the file so that the namespaces are consistent. Run:

java -cp lib/icu4j-3.4.4.jar:lib/jena-arq-2.9.0-incubating.jar:lib/jena-core-2.7.0-incubating.jar:lib/jena-iri-0.9.0-incubating.jar:lib/log4j-1.2.16.jar:lib/slf4j-api-1.6.4.jar:lib/slf4j-log4j12-1.6.4.jar:lib/xercesImpl-2.10.0.jar:lib/xml-apis-1.4.01.jar jena.schemagen -i $inputFile -o "./src" --package "de.fraunhofer.scai.bio.uima.xcas2rdf.vocabulary" --owl -a "http://purl.org/pav/" pav

.. and it will generate what is expected.

Another tip is to add  --ontology to get OntProperty, OntClass, etc, declarations generated in the output file.

Keine Kommentare:

Kommentar veröffentlichen