我正在用耶拿创建rdf / xml格式的OWL。
我可以为如下所示的班级创建个人
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)
jena将其写入文件的形式
<!-- 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>
现在我想在耶拿的[[个人 白葡萄酒和红肉之间创建对象属性声明
这将导致(下面的例子是在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>
感谢您对此的所有帮助
创建对象属性
predicate和个体whiteWine and redMeat(就像所讨论的代码之后),只需使用ModelCon.add(resource,predicate,rdfNode)添加以下代码model.add(whiteWine, predicate, redMeat)
导致]
<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>
现在我得到了想要的结果,但是代码只是做什么?