我为传感器服务提供商创建了这个本体,这是一个室内传感器网络系统的模块。我的问题是,当我在我的本体上运行查询时,它给了我一些类的答案,而对于其他类,它什么也没有返回,也没有给出任何错误。例如,为了获得一个类的个体,“Device”“SensorServiceProvider”和“Information class”什么都不返回,而对于其他casses,它返回个体。我从代码中删除了一些链接。
这是本体数据:
<?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 rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY p0
"http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#">]>
<rdf:RDF
xmlns="http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#"
xml:base="http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:p0="http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#"
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#">
<owl:Ontology
rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation">
<owl:imports
rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation"/>
</owl:Ontology>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#ConnectsTo
-->
<owl:ObjectProperty rdf:about="&p0;ConnectsTo">
<rdf:type rdf:resource="&owl;TransitiveProperty"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Implement
-->
<owl:ObjectProperty rdf:about="&p0;Implement">
<rdfs:range rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensing"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Store -->
<owl:ObjectProperty rdf:about="&p0;Store">
<rdfs:range rdf:resource="&p0;Information"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#SensorServiceProvider"/>
</owl:ObjectProperty>
<!--
http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#hasInformation
-->
<owl:ObjectProperty rdf:about="&p0;hasInformation"/>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#initiates
-->
<owl:ObjectProperty rdf:about="&p0;initiates">
<rdfs:range rdf:resource="&p0;Management"/>
<rdfs:domain rdf:resource="&p0;SensorSupportToolbox"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#manage -->
<owl:ObjectProperty rdf:about="&p0;manage">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#ContentService"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Middleware_Information"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor_Information"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#provide --
>
<owl:ObjectProperty rdf:about="&p0;provide">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#SensorServiceProvider"/>
<rdfs:range rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Services"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!--
http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MiddlewareCode
-->
<owl:DatatypeProperty rdf:about="&p0;MiddlewareCode">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Middleware_Information"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!--
http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MiddlewareID
-->
<owl:DatatypeProperty rdf:about="&p0;MiddlewareID">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Middleware_Information"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!--
http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MiddlewareRight
-->
<owl:DatatypeProperty rdf:about="&p0;MiddlewareRight">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Middleware_Information"/>
<rdfs:range rdf:resource="&xsd;boolean"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#NodeCode -
->
<owl:DatatypeProperty rdf:about="&p0;NodeCode">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor_Information"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!--
http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#NodeExplain -->
<owl:DatatypeProperty rdf:about="&p0;NodeExplain">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor_Information"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#NodeId -->
<owl:DatatypeProperty rdf:about="&p0;NodeId">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor_Information"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#NodeName -
->
<owl:DatatypeProperty rdf:about="&p0;NodeName">
<rdfs:domain rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-
ontology-41#Sensor_Information"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<owl:Class rdf:about="&p0;Application_Server"/>
<owl:Class rdf:about="&p0;Information"/>
<owl:Class rdf:about="&p0;Management"/>
<owl:Class rdf:about="&p0;MiddlewareManagement">
<rdfs:subClassOf rdf:resource="&p0;Management"/>
</owl:Class>
<owl:Class rdf:about="&p0;ProviderManagement">
<rdfs:subClassOf rdf:resource="&p0;Management"/>
</owl:Class>
<owl:Class rdf:about="&p0;SensorManagement">
<rdfs:subClassOf rdf:resource="&p0;Management"/>
</owl:Class>
<owl:Class rdf:about="&p0;SensorMiddleware">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&p0;ConnectsTo"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensorServiceProvider"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:about="&p0;SensorSupportToolbox"/>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#ContentService">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Services"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Device">
<rdfs:subClassOf rdf:resource="&owl;Thing"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&p0;ConnectsTo"/>
<owl:someValuesFrom rdf:resource="&p0;SensorMiddleware"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Middleware_Information">
<rdfs:subClassOf rdf:resource="&p0;Information"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Process"/>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#ProviderService -->
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#ProviderService">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Services"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensing">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Process"/>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensingService -->
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensingService">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Services"/>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensing_Device -->
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensing_Device">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Device"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Device"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensorServiceProvider">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&p0;ConnectsTo"/>
<owl:someValuesFrom rdf:resource="&p0;Application_Server"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor_Information">
<rdfs:subClassOf rdf:resource="&p0;Information"/>
</owl:Class>
<owl:Class rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Services"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#APPServer -->
<owl:NamedIndividual rdf:about="&p0;APPServer">
<rdf:type rdf:resource="&p0;Application_Server"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MW1 -->
<owl:NamedIndividual rdf:about="&p0;MW1">
<rdf:type rdf:resource="&p0;SensorMiddleware"/>
<hasInformation rdf:resource="&p0;MiddlewareInfo"/>
<ConnectsTo rdf:resource="&p0;SSP1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MW2 -->
<owl:NamedIndividual rdf:about="&p0;MW2">
<rdf:type rdf:resource="&p0;SensorMiddleware"/>
<hasInformation rdf:resource="&p0;MiddlewareInfo"/>
<ConnectsTo rdf:resource="&p0;SSP1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MW3 -->
<owl:NamedIndividual rdf:about="&p0;MW3">
<rdf:type rdf:resource="&p0;SensorMiddleware"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Management1 -->
<owl:NamedIndividual rdf:about="&p0;Management1">
<rdf:type rdf:resource="&p0;Management"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#MiddlewareInfo -->
<owl:NamedIndividual rdf:about="&p0;MiddlewareInfo">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Middleware_Information"/>
<MiddlewareCode rdf:datatype="&xsd;integer">021</MiddlewareCode>
<MiddlewareID rdf:datatype="&xsd;integer">MW021</MiddlewareID>
<MiddlewareRight rdf:datatype="&xsd;boolean">false</MiddlewareRight>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#SSP1 -->
<owl:NamedIndividual rdf:about="&p0;SSP1">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensorServiceProvider"/>
<ConnectsTo rdf:resource="&p0;APPServer"/>
<Store rdf:resource="&p0;MiddlewareInfo"/>
<Store rdf:resource="&p0;SensorInfo"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#SSP2 -->
<owl:NamedIndividual rdf:about="&p0;SSP2">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#SensorServiceProvider"/>
<Store rdf:resource="&p0;MiddlewareInfo"/>
<Store rdf:resource="&p0;SensorInfo"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#SST1 -->
<owl:NamedIndividual rdf:about="&p0;SST1">
<rdf:type rdf:resource="&p0;SensorSupportToolbox"/>
<initiates rdf:resource="&p0;Management1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Sensor1 -->
<owl:NamedIndividual rdf:about="&p0;Sensor1">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor"/>
<ConnectsTo rdf:resource="&p0;MW1"/>
<hasInformation rdf:resource="&p0;SensorInfo"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Sensor2 -->
<owl:NamedIndividual rdf:about="&p0;Sensor2">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor"/>
<ConnectsTo rdf:resource="&p0;MW2"/>
<hasInformation rdf:resource="&p0;SensorInfo"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#SensorInfo -->
<owl:NamedIndividual rdf:about="&p0;SensorInfo">
<rdf:type rdf:resource="http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor_Information"/>
<NodeCode rdf:datatype="&xsd;integer">021</NodeCode>
<NodeId rdf:datatype="&xsd;string">sd021</NodeId>
<NodeName rdf:datatype="&xsd;string">sensor021</NodeName>
<NodeExplain rdf:datatype="&xsd;string">temp</NodeExplain>
</owl:NamedIndividual>
</rdf:RDF>
我正在运行的查询是:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX p0: <http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#>
SELECT ?x
WHERE {?x rdf:type p0:Information}
如果不清楚,我可以提供更多细节。
答案 0 :(得分:0)
我将您的数据加载到Sesame商店并执行了一些查询以查看发生了什么。
您正在执行的查询尝试检索类http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#Information
的所有实例。但是,您的数据不包含此类的实例,因此结果为空。
通过运行查询,我们可以很容易地看到这一点:
PREFIX p0: <http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#>
DESCRIBE p0:Information
给了我们这个结果:
p0:Information rdf:type owl:Class .
p0:Store rdfs:range p0:Information .
<http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Middleware_Information> rdfs:subClassOf p0:Information .
<http://www.semanticweb.org/faiza/ontologies/2014/7/untitled-ontology-41#Sensor_Information> rdfs:subClassOf p0:Information .
如您所见,没有三元组以rdf:type
作为谓词,p0:Information
作为对象,因此没有可用的实例。
但是,是本体中p0:Information
的两个子类,它们可能有实例。你期待得到那些回来吗?这只有在您查询的商店启用了RDFS推理时才会起作用 - 默认情况下大多数三重存储都不启用。
因此,如果您想要获取子类的实例,请在您的triplestore上启用推理,或者使用以下查询:
PREFIX p0: <http://www.semanticweb.org/faiza/ontologies/2014/10/serviceproviderimplementation#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?x
WHERE {
?x rdf:type/rdfs:subClassOf* p0:Information .
}
这使用属性路径来检索所有值?x
,这些值通过零{或更多rdfs:subClassOf
关系与p0:Information
相关联。