Java Jena OWL/RDF功能属性
我需要实现这样的OWL格式:Java Jena OWL/RDF功能属性,java,rdf,jena,owl,Java,Rdf,Jena,Owl,我需要实现这样的OWL格式: <owl:DatatypeProperty rdf:ID="Role-description"> <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> <rdfs:domain rdf:resource="#Role"/> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Functi
<owl:DatatypeProperty rdf:ID="Role-description"> <rdfs:range
rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
<rdfs:domain rdf:resource="#Role"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
得到所有的虎钳,反之亦然
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<owl:Class rdf:about="http://www.w3.org/2002/07/owl#Task"/>
<owl:Class rdf:about="http://www.w3.org/2002/07/owl#Actor"/>
<owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#Task-performedBy-Actor"/>
<owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#Actor-performs-Task"/>
<owl:FunctionalProperty rdf:about="http://www.w3.org/2002/07/owl#Role-description">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
</owl:FunctionalProperty>
</rdf:RDF>
如果您有任何建议,我们将不胜感激。您得到的输出并非相反。您基本上拥有的是具有多种类型的RDF资源。这取决于耶拿如何序列化他们(即哪一个考虑“初级”)。为了举例说明,我将把您的示例序列化为Turtle(稍作修改以使用自定义名称空间): 它产生以下输出:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:roles="http://example.com/ns/roles#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<owl:DatatypeProperty rdf:about="http://example.com/ns/roles#Role-description">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
</owl:DatatypeProperty>
</rdf:RDF>
我不明白数据序列化的重要性。语义应该是相同的,任何适当的解析器都将从中获得相同的完整和正确的信息。OWL的序列化没有顺序,因为OWL本体由一组OWL组成axioms@AKSW我经常看到类似的“需求”,通常是由于过度指定的请求或任务。通常也是与非RDF或非OWL工具链交互的结果。
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix roles: <http://example.com/ns/roles#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
roles:Role-description
a owl:DatatypeProperty , owl:FunctionalProperty .
public static final String ROLES_NS = "http://example.com/ns/roles#";
public static void main(String[] args) {
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
ontModel.setNsPrefix("roles", ROLES_NS);
DatatypeProperty prop = ontModel.createDatatypeProperty(
ROLES_NS + "Role-description");
prop.setRDFType(OWL.FunctionalProperty);
prop.addRDFType(OWL.DatatypeProperty);
RDFDataMgr.write(System.out, ontModel, RDFFormat.RDFXML_PRETTY);
}
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:roles="http://example.com/ns/roles#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
<owl:DatatypeProperty rdf:about="http://example.com/ns/roles#Role-description">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
</owl:DatatypeProperty>
</rdf:RDF>