On Fri, Jul 8, 2016 at 4:10 PM, tina sani <[email protected]> wrote:
> I have an Rdf file created in Protege, named Company.rdf which have several
> classes and properties. The file is in C:/users/desktop/Company.rdf. The
> ontology URI is www.Sales.owl
>
> I want to add another class using Jena i-e Customer, so I am confuse about
> the uri ?
> I mean what will be the class Customer URI and where in the code I will
> mention this uri?

You'd typically load the file into a Jena OntModel [1], and then use
the methods provided there to create the new class.  In particular,
you'd want createClass(String) [2].  You can use whatever URI you want
for the new class;  RDF and OWL use URIs/IRIs as identifiers, but
don't attach any meaning to the URIs/IRIs that are used.  You can use
whatever you like.  It might be considered good practice to keep using
whatever convention you've used so far, though.  E.g., if you've
already created `http://example.org/Company` as a class, then you'd
probably want Customer to be `http://example.org/Customer`.

Then you just need to write the updated model out to a file.  Jena
models exist *in memory*;  no change happens on the disk just because
you change an *in memory* model.  So you must write the updated model
to a new file or overwrite the existing model. I think the latest ways
for writing models are now provided by RDFDataMgr [3].

[1] 
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html
[2] 
https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/ontology/OntModel.html#createClass-java.lang.String-
[3] 
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/riot/RDFDataMgr.html

> **(Also is it mandatory to mention the URI because we already have to read*
> *the  rdf file using FileManager.get().open( inputFileName )*

The URI of the ontology doesn't matter;  You're opening a *file on
disk*, so you need the pathname.

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to