I am creating a OWL in rdf/xml format with jena.
I am able to create a individual for a class like below
OntClass wine = model.createClass(uri + "#wine")
OntClass meat = model.createClass(uri + "#meat")
ObjectProperty predicate = model.createObjectProperty(uriBase + "#goes_well_with")
predicate.addDomain(wine)
predicate.addRange(meat)
Individual whiteWine = wine.createIndividual(uri + "white_wine")
Individual redMeat = meat.creatIndividual(uri + "red_meat")
whiteWine.addRDFType(OWL2.NamedIndividual)
redMeat.addRDFType(OWL2.NamedIndividual)
which jena writes into a file as
<!-- classes -->
<owl:Class rdf:about="http://www.example.com/ontology#wine"/>
<owl:Class rdf:about="http://www.example.com/ontology#meat"/>
<!-- object property -->
<owl:ObjectProperty rdf:about="http://www.example.com/ontology#goes_well_with">
<rdfs:domain rdf:resource="http://www.example.com/ontology#wine"/>
<rdfs:range rdf:resource="http://www.example.com/ontology#meat"/>
</owl:ObjectProperty>
<!-- individuals -->
<owl:NamedIndividual rdf:about="http://www.example.com/ontology#white_wine">
<rdf:type rdf:resource="http://www.example.com/ontology#wine"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.example.com/ontology#red_meat">
<rdf:type rdf:resource="http://www.example.com/ontology#meat"/>
</owl:NamedIndividual>
now I wanted to create object property assertion between individuals white_wine and red_meat in jena
which will result in (below example manually created in protege)
<owl:NamedIndividual rdf:about="http://www.example.com/ontology#white_wine">
<rdf:type rdf:resource="http://www.example.com/ontology#wine"/>
<!-- this is the part I am unable to render with jena -->
<goes_well_with rdf:resource="http://www.example.com/ontology#red_meat"/>
<!-------------------->
</owl:NamedIndividual>
appreciate all your help on this
I found a sample code snippet which gave me the expected result.
After creating the object property predicate and individuals whiteWine and redMeat (like the code in question) just add below code using ModelCon.add(resource,predicate,rdfNode)
model.add(whiteWine, predicate, redMeat)
or as mentioned by @ASKW in the comment
whiteWine.addProperty(predicate, redMeat)
works as well.
which results in
<owl:NamedIndividual rdf:about="http://www.example.com/ontology#white_wine">
<rdf:type rdf:resource="http://www.example.com/ontology#wine"/>
<goes_well_with rdf:resource="http://www.example.com/ontology#red_meat"/>
</owl:NamedIndividual>
Now I got the result I wanted, however
appreciate your help.