我是本体论的新手.我正在使用protege 4.3创建一个.owl文件.我通过使用SPARQL查询访问对象属性,例如:
Prefix: <http://www.workingontologist.org/Examples/Chapter3/Product.owl#>
select ?x ?y where {
?x :hasPizza ?y
}
这很好,并显示与该成员相关的所有对象属性.
当我从该owl文件访问数据属性时,我无法读取或访问数据属性
请提供有关如何从该owl文件访问数据属性的建议
谢谢你的帮助
我的猫头鹰文件是
<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY daml "http://www.daml.org/2001/03/daml+oil#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY mfg "http://www.workingontologist.org/Examples/Chapter3/Product.owl#" >
]>
<rdf:RDF xmlns="http://www.workingontologist.org/Examples/Chapter3/Product.owl#"
xml:base="http://www.workingontologist.org/Examples/Chapter3/Product.owl"
xmlns:mfg="http://www.workingontologist.org/Examples/Chapter3/Product.owl#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:daml="http://www.daml.org/2001/03/daml+oil#">
<owl:Ontology rdf:about="http://www.workingontologist.org/Examples/Chapter3/Product.owl">
<owl:versionInfo rdf:datatype="&xsd;string">Created with TopBraid Spreadsheet converter</owl:versionInfo>
</owl:Ontology>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#hasPizza -->
<owl:ObjectProperty rdf:about="&mfg;hasPizza"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Available -->
<owl:DatatypeProperty rdf:about="&mfg;Product_Available">
<rdfs:label rdf:datatype="&xsd;string">Available</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Division -->
<owl:DatatypeProperty rdf:about="&mfg;Product_Division">
<rdfs:label rdf:datatype="&xsd;string">Division</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_ID -->
<owl:DatatypeProperty rdf:about="&mfg;Product_ID">
<rdfs:label rdf:datatype="&xsd;string">ID</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Manufacture_Location -->
<owl:DatatypeProperty rdf:about="&mfg;Product_Manufacture_Location">
<rdfs:label rdf:datatype="&xsd;string">Manufacture Location</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_ModelNo -->
<owl:DatatypeProperty rdf:about="&mfg;Product_ModelNo">
<rdfs:label rdf:datatype="&xsd;string">ModelNo</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_Product_Line -->
<owl:DatatypeProperty rdf:about="&mfg;Product_Product_Line">
<rdfs:label rdf:datatype="&xsd;string">Product Line</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_SKU -->
<owl:DatatypeProperty rdf:about="&mfg;Product_SKU">
<rdfs:label rdf:datatype="&xsd;string">SKU</rdfs:label>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:domain rdf:resource="&mfg;Product"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product -->
<owl:Class rdf:about="&mfg;Product"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product1 -->
<owl:NamedIndividual rdf:about="&mfg;Product1">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 1</rdfs:label>
<Product_ID rdf:datatype="&xsd;string">1</Product_ID>
<Product_Available rdf:datatype="&xsd;string">23</Product_Available>
<Product_SKU rdf:datatype="&xsd;string">FB3524</Product_SKU>
<Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
<Product_Product_Line rdf:datatype="&xsd;string">Papermachine</Product_Product_Line>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
<Product_ModelNo rdf:datatype="&xsd;string">ZX-3</Product_ModelNo>
<hasPizza rdf:resource="&mfg;Product1"/>
<hasPizza rdf:resource="&mfg;Product2"/>
<hasPizza rdf:resource="&mfg;Product3"/>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product2 -->
<owl:NamedIndividual rdf:about="&mfg;Product2">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 2</rdfs:label>
<Product_ID rdf:datatype="&xsd;string">2</Product_ID>
<Product_Available rdf:datatype="&xsd;string">4</Product_Available>
<Product_SKU rdf:datatype="&xsd;string">KD5243</Product_SKU>
<Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
<Product_Product_Line rdf:datatype="&xsd;string">Paper machine</Product_Product_Line>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
<Product_ModelNo rdf:datatype="&xsd;string">ZX-3P</Product_ModelNo>
<hasPizza rdf:resource="&mfg;Product2"/>
<hasPizza rdf:resource="&mfg;Product7"/>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product3 -->
<owl:NamedIndividual rdf:about="&mfg;Product3">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 3</rdfs:label>
<Product_ID rdf:datatype="&xsd;string">3</Product_ID>
<Product_Available rdf:datatype="&xsd;string">34</Product_Available>
<Product_SKU rdf:datatype="&xsd;string">IL4028</Product_SKU>
<Product_Division rdf:datatype="&xsd;string">Manufacturing support</Product_Division>
<Product_Product_Line rdf:datatype="&xsd;string">Paper machine</Product_Product_Line>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Sacramento</Product_Manufacture_Location>
<Product_ModelNo rdf:datatype="&xsd;string">ZX-3S</Product_ModelNo>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product4 -->
<owl:NamedIndividual rdf:about="&mfg;Product4">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 4</rdfs:label>
<Product_Available rdf:datatype="&xsd;string">23</Product_Available>
<Product_ID rdf:datatype="&xsd;string">4</Product_ID>
<Product_ModelNo rdf:datatype="&xsd;string">B-1430</Product_ModelNo>
<Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Elizabeth</Product_Manufacture_Location>
<Product_Product_Line rdf:datatype="&xsd;string">Feedback line</Product_Product_Line>
<Product_SKU rdf:datatype="&xsd;string">KS4520</Product_SKU>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product5 -->
<owl:NamedIndividual rdf:about="&mfg;Product5">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 5</rdfs:label>
<Product_Available rdf:datatype="&xsd;string">14</Product_Available>
<Product_ID rdf:datatype="&xsd;string">5</Product_ID>
<Product_ModelNo rdf:datatype="&xsd;string">B-1430X</Product_ModelNo>
<Product_SKU rdf:datatype="&xsd;string">CL5934</Product_SKU>
<Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Elizabeth</Product_Manufacture_Location>
<Product_Product_Line rdf:datatype="&xsd;string">Feedback line</Product_Product_Line>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product6 -->
<owl:NamedIndividual rdf:about="&mfg;Product6">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 6</rdfs:label>
<Product_Available rdf:datatype="&xsd;string">0</Product_Available>
<Product_ID rdf:datatype="&xsd;string">6</Product_ID>
<Product_Product_Line rdf:datatype="&xsd;string">Active sensor</Product_Product_Line>
<Product_ModelNo rdf:datatype="&xsd;string">B-1431</Product_ModelNo>
<Product_Division rdf:datatype="&xsd;string">Control Engineering</Product_Division>
<Product_SKU rdf:datatype="&xsd;string">KK3945</Product_SKU>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Seoul</Product_Manufacture_Location>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product7 -->
<owl:NamedIndividual rdf:about="&mfg;Product7">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 7</rdfs:label>
<Product_Available rdf:datatype="&xsd;string">100</Product_Available>
<Product_ID rdf:datatype="&xsd;string">7</Product_ID>
<Product_Division rdf:datatype="&xsd;string">Accessories</Product_Division>
<Product_ModelNo rdf:datatype="&xsd;string">DBB-12</Product_ModelNo>
<Product_Manufacture_Location rdf:datatype="&xsd;string">Hong Kong</Product_Manufacture_Location>
<Product_Product_Line rdf:datatype="&xsd;string">Monitor</Product_Product_Line>
<Product_SKU rdf:datatype="&xsd;string">ND5520</Product_SKU>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product8 -->
<owl:NamedIndividual rdf:about="&mfg;Product8">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 8</rdfs:label>
<Product_ID rdf:datatype="&xsd;string">8</Product_ID>
<Product_SKU rdf:datatype="&xsd;string">Cleveland</Product_SKU>
<Product_Available rdf:datatype="&xsd;string">HI4554</Product_Available>
<Product_ModelNo rdf:datatype="&xsd;string">SP-1234</Product_ModelNo>
<Product_Division rdf:datatype="&xsd;string">Safety</Product_Division>
<Product_Product_Line rdf:datatype="&xsd;string">Safety</Product_Product_Line>
<Product_Manufacture_Location rdf:datatype="&xsd;string">valve</Product_Manufacture_Location>
</owl:NamedIndividual>
<!-- http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product9 -->
<owl:NamedIndividual rdf:about="&mfg;Product9">
<rdf:type rdf:resource="&mfg;Product"/>
<rdfs:label rdf:datatype="&xsd;string">Product 9</rdfs:label>
<Product_ID rdf:datatype="&xsd;string">9</Product_ID>
<Product_SKU rdf:datatype="&xsd;string">Cleveland</Product_SKU>
<Product_Available rdf:datatype="&xsd;string">OP5333</Product_Available>
<Product_ModelNo rdf:datatype="&xsd;string">SPX-1234</Product_ModelNo>
<Product_Product_Line rdf:datatype="&xsd;string">Safety</Product_Product_Line>
<Product_Division rdf:datatype="&xsd;string">Safety</Product_Division>
<Product_Manufacture_Location rdf:datatype="&xsd;string">valve</Product_Manufacture_Location>
</owl:NamedIndividual>
<rdf:Description>
<Product_ID></Product_ID>
</rdf:Description>
</rdf:RDF>
最佳答案 在您的数据中,IRI有一个数据类型属性http://www.workingontologist.org/Examples/Chapter3/Product.owl#Product_SKU.您可以使用SPARQL查询检索该谓词的主题和对象,如下所示:
prefix mfg: <http://www.workingontologist.org/Examples/Chapter3/Product.owl#>
select ?x ?y where {
?x mfg:Product_SKU ?y
}
-------------------------------------------------------------------------
| x | y |
=========================================================================
| mfg:Product9 | "Cleveland"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product8 | "Cleveland"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product7 | "ND5520"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product6 | "KK3945"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product5 | "CL5934"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product4 | "KS4520"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product3 | "IL4028"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product2 | "KD5243"^^<http://www.w3.org/2001/XMLSchema#string> |
| mfg:Product1 | "FB3524"^^<http://www.w3.org/2001/XMLSchema#string> |
-------------------------------------------------------------------------