我正在使用dotnetrdf编写sparql查询来获取保存在我的本体中的执行器的类型,id和解释属性。即时通讯使用以下选择查询。
"PREFIX AP0: <http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#> " +
"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#>" +
"SELECT *"+
"WHERE {"+
"?Name rdf:type AP0:Actuating_Device."+
"?Name AP0:ActuatorID ?id."+
"?Name AP0:ActuatorExplain ?Explain."+
"?Name AP0:AcuatorCode "txtActuatorID.Text"}"
使用此方法显示结果
public void datadisplay1(IEnumerable<string> variables, SparqlResultSet srs)
{
dataGridView1.Columns.Clear();
int vn = 0;
foreach (string v in variables)
{
dataGridView1.Columns.Add(v, v); ;
this.dataGridView1.Columns[vn].Width = 300;
vn++;
}
foreach (SparqlResult r in srs)
{
int i = 0;
object[] items = new object[vn];
foreach (string s in variables)
{
items[i++] = r.Value(s);
}
dataGridView1.Rows.Add(items );
}
这是我的猫头鹰文件
<?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 ace_lexicon "http://attempto.ifi.uzh.ch/ace_lexicon#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY AP0 "http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider" >
<!ENTITY ActuatorProvider "http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#" >
]>
<rdf:RDF xmlns="&AP0;#"
xml:base="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"
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:AP0="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"
xmlns:ActuatorProvider="&AP0;#"
xmlns:ace_lexicon="http://attempto.ifi.uzh.ch/ace_lexicon#">
<owl:Ontology rdf:about="http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Annotation properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#CN_pl -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;CN_pl"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#CN_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;CN_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#PN_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;PN_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_pl -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_pl"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_sg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_sg"/>
<!-- http://attempto.ifi.uzh.ch/ace_lexicon#TV_vbg -->
<owl:AnnotationProperty rdf:about="&ace_lexicon;TV_vbg"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ConnectsTo -->
<owl:ObjectProperty rdf:about="&AP0;#ConnectsTo">
<ace_lexicon:TV_pl>ConnectsTo</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>ConnectsToes</ace_lexicon:TV_sg>
<ace_lexicon:TV_vbg>ConnectsToed</ace_lexicon:TV_vbg>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Perform -->
<owl:ObjectProperty rdf:about="&AP0;#Perform">
<ace_lexicon:TV_pl>Perform</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Performed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>Performs</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
<rdfs:range rdf:resource="&AP0;#Management"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Provide -->
<owl:ObjectProperty rdf:about="&AP0;#Provide">
<ace_lexicon:TV_sg>Provides</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>Provide</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Provided</ace_lexicon:TV_vbg>
<rdfs:range rdf:resource="&AP0;#APServices"/>
<rdfs:domain rdf:resource="&AP0;#Actuator_Service_Provider"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Use -->
<owl:ObjectProperty rdf:about="&AP0;#Use">
<ace_lexicon:TV_pl>Use</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>Used</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>Uses</ace_lexicon:TV_sg>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#hasState -->
<owl:ObjectProperty rdf:about="&AP0;#hasState">
<rdf:type rdf:resource="&owl;FunctionalProperty"/>
<ace_lexicon:TV_pl>hasState</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>hasStated</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>hasStates</ace_lexicon:TV_sg>
<rdfs:range rdf:resource="&AP0;#Actuator_State"/>
<rdfs:domain rdf:resource="&AP0;#Device"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorCode -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorCode">
<ace_lexicon:TV_sg>ActuatorCodes</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>ActuatorCode</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorCoded</ace_lexicon:TV_vbg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorExplain -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorExplain">
<ace_lexicon:TV_vbg>ActuatorExplained</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorExplains</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>ActuatorExplain</ace_lexicon:TV_pl>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
<rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorID -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorID">
<ace_lexicon:TV_pl>ActuatorID</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorIDed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorIDs</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorName -->
<owl:DatatypeProperty rdf:about="&AP0;#ActuatorName">
<ace_lexicon:TV_pl>ActuatorName</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>ActuatorNamed</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>ActuatorNames</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareCode -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareCode">
<ace_lexicon:TV_vbg>MiddlewareCoded</ace_lexicon:TV_vbg>
<ace_lexicon:TV_pl>MiddlewareCode</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>MiddlewareCodes</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareID -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareID">
<ace_lexicon:TV_sg>MiddlewareIDs</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>MiddlewareID</ace_lexicon:TV_pl>
<ace_lexicon:TV_vbg>MiddlewareIDed</ace_lexicon:TV_vbg>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;string"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#MiddlewareRight -->
<owl:DatatypeProperty rdf:about="&AP0;#MiddlewareRight">
<ace_lexicon:TV_vbg>MiddlewareRighted</ace_lexicon:TV_vbg>
<ace_lexicon:TV_sg>MiddlewareRights</ace_lexicon:TV_sg>
<ace_lexicon:TV_pl>MiddlewareRight</ace_lexicon:TV_pl>
<rdfs:domain rdf:resource="&AP0;#Actuator_Middleware"/>
<rdfs:range rdf:resource="&xsd;boolean"/>
</owl:DatatypeProperty>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#PowerConsumption -->
<owl:DatatypeProperty rdf:about="&AP0;#PowerConsumption">
<ace_lexicon:TV_vbg>PowerConsumptioned</ace_lexicon:TV_vbg>
<ace_lexicon:TV_pl>PowerConsumption</ace_lexicon:TV_pl>
<ace_lexicon:TV_sg>PowerConsumptions</ace_lexicon:TV_sg>
<rdfs:domain rdf:resource="&AP0;#Actuating_Device"/>
<rdfs:range rdf:resource="&xsd;integer"/>
</owl:DatatypeProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#APServices -->
<owl:Class rdf:about="&AP0;#APServices">
<ace_lexicon:CN_pl>APServiceses</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>APServices</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuating_Device -->
<owl:Class rdf:about="&AP0;#Actuating_Device">
<rdfs:subClassOf rdf:resource="&AP0;#Device"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#hasState"/>
<owl:onClass rdf:resource="&AP0;#Actuator_State"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuating_Device</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuating_Devices</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Content_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Content_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_pl>Actuator_Content_Services</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Actuator_Content_Service</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Control_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Control_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_sg>Actuator_Control_Service</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Control_Services</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Info_Management -->
<owl:Class rdf:about="&AP0;#Actuator_Info_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Content_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Info_Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Info_Managements</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Middleware -->
<owl:Class rdf:about="&AP0;#Actuator_Middleware">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:onClass rdf:resource="&AP0;#Actuator_Service_Provider"/>
<owl:maxQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxQualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Control_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Middleware</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Middlewares</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Provider_Service -->
<owl:Class rdf:about="&AP0;#Actuator_Provider_Service">
<rdfs:subClassOf rdf:resource="&AP0;#APServices"/>
<ace_lexicon:CN_sg>Actuator_Provider_Service</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Provider_Services</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Service_Provider -->
<owl:Class rdf:about="&AP0;#Actuator_Service_Provider">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Actuator_Service_Provider</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_Service_Providers</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_State -->
<owl:Class rdf:about="&AP0;#Actuator_State">
<ace_lexicon:CN_sg>Actuator_State</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Actuator_States</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Actuator_Support_Toolbox -->
<owl:Class rdf:about="&AP0;#Actuator_Support_Toolbox">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Perform"/>
<owl:someValuesFrom rdf:resource="&AP0;#Management"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_pl>Actuator_Support_Toolboxes</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Actuator_Support_Toolbox</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Device -->
<owl:Class rdf:about="&AP0;#Device">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#hasState"/>
<owl:onClass rdf:resource="&AP0;#Actuator_State"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#ConnectsTo"/>
<owl:onClass rdf:resource="&AP0;#Actuator_Middleware"/>
<owl:maxQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxQualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_sg>Device</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Devices</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Management -->
<owl:Class rdf:about="&AP0;#Management">
<ace_lexicon:CN_sg>Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Managements</ace_lexicon:CN_pl>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Middleware_Access_Management -->
<owl:Class rdf:about="&AP0;#Middleware_Access_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&AP0;#Use"/>
<owl:someValuesFrom rdf:resource="&AP0;#Actuator_Content_Service"/>
</owl:Restriction>
</rdfs:subClassOf>
<ace_lexicon:CN_pl>Middleware_Access_Managements</ace_lexicon:CN_pl>
<ace_lexicon:CN_sg>Middleware_Access_Management</ace_lexicon:CN_sg>
</owl:Class>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Service_Info_Management -->
<owl:Class rdf:about="&AP0;#Service_Info_Management">
<rdfs:subClassOf rdf:resource="&AP0;#Management"/>
<ace_lexicon:CN_sg>Service_Info_Management</ace_lexicon:CN_sg>
<ace_lexicon:CN_pl>Service_Info_Managements</ace_lexicon:CN_pl>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice1">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ActuatorName rdf:datatype="&xsd;string">"Fan"</ActuatorName>
<ActuatorID rdf:datatype="&xsd;string">"SD01"</ActuatorID>
<ActuatorExplain rdf:datatype="&xsd;string">"TemperatureControl"</ActuatorExplain>
<ActuatorCode rdf:datatype="&xsd;integer">1</ActuatorCode>
<PowerConsumption rdf:datatype="&xsd;integer">400</PowerConsumption>
<ace_lexicon:PN_sg>ActuatingDevice1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware1"/>
<hasState rdf:resource="&AP0;#Offline"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice2 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice2">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ActuatorExplain rdf:datatype="&xsd;string">"AirConditioner"</ActuatorExplain>
<ActuatorID rdf:datatype="&xsd;string">"DS02"</ActuatorID>
<ActuatorName rdf:datatype="&xsd;string">"LabConditioner"</ActuatorName>
<PowerConsumption rdf:datatype="&xsd;integer">1300</PowerConsumption>
<ActuatorCode rdf:datatype="&xsd;integer">2</ActuatorCode>
<ace_lexicon:PN_sg>ActuatingDevice2</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware1"/>
<hasState rdf:resource="&AP0;#Online"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice3 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatingDevice3">
<rdf:type rdf:resource="&AP0;#Actuating_Device"/>
<ace_lexicon:PN_sg>ActuatingDevice3</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorMiddleware2"/>
<hasState rdf:resource="&AP0;#Waiting"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorMiddleware1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorMiddleware1">
<rdf:type rdf:resource="&AP0;#Actuator_Middleware"/>
<MiddlewareID rdf:datatype="&xsd;string">"MW101"</MiddlewareID>
<MiddlewareCode rdf:datatype="&xsd;integer">1</MiddlewareCode>
<MiddlewareRight rdf:datatype="&xsd;boolean">false</MiddlewareRight>
<ace_lexicon:PN_sg>ActuatorMiddleware1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorServiceProvider1"/>
<Use rdf:resource="&AP0;#ControlService1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorMiddleware2 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorMiddleware2">
<rdf:type rdf:resource="&AP0;#Actuator_Middleware"/>
<MiddlewareID rdf:datatype="&xsd;string">"MW102"</MiddlewareID>
<MiddlewareCode rdf:datatype="&xsd;integer">2</MiddlewareCode>
<MiddlewareRight rdf:datatype="&xsd;boolean">true</MiddlewareRight>
<ace_lexicon:PN_sg>ActuatorMiddleware2</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorServiceProvider1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorServiceProvider1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorServiceProvider1">
<rdf:type rdf:resource="&AP0;#Actuator_Service_Provider"/>
<ace_lexicon:PN_sg>ActuatorServiceProvider1</ace_lexicon:PN_sg>
<ConnectsTo rdf:resource="&AP0;#ActuatorSupportToolbox1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatorSupportToolbox1 -->
<owl:NamedIndividual rdf:about="&AP0;#ActuatorSupportToolbox1">
<rdf:type rdf:resource="&AP0;#Actuator_Support_Toolbox"/>
<ace_lexicon:PN_sg>ActuatorSupportToolbox1</ace_lexicon:PN_sg>
<Perform rdf:resource="&AP0;#Management1"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ControlService1 -->
<owl:NamedIndividual rdf:about="&AP0;#ControlService1">
<ace_lexicon:PN_sg>ControlService1</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Management1 -->
<owl:NamedIndividual rdf:about="&AP0;#Management1">
<ace_lexicon:PN_sg>Management1</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Offline -->
<owl:NamedIndividual rdf:about="&AP0;#Offline">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Offline</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Online -->
<owl:NamedIndividual rdf:about="&AP0;#Online">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Online</ace_lexicon:PN_sg>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#Waiting -->
<owl:NamedIndividual rdf:about="&AP0;#Waiting">
<rdf:type rdf:resource="&AP0;#Actuator_State"/>
<ace_lexicon:PN_sg>Waiting</ace_lexicon:PN_sg>
</owl:NamedIndividual>
</rdf:RDF>
我在c#中使用gridview来显示结果。它以这种形式给我结果
http://www.semanticweb.org/faiza/ontologies/2014/10/ActuatorProvider#ActuatingDevice1
TemperatureControl^^http://www.w3.org/2001/XMLSchema#anyURI
SD01^^http://www.w3.org/2001/XMLSchema#anyURI
如何从结果中删除URI。
答案 0 :(得分:2)
您还没有展示完整的示例,因此我们无法告诉您如何显示SPARQL结果,因此很难回答您的具体问题(因为您还没有说明一个!) 。但是我可以尝试提供一些一般性的指示。
您看到的数据是每列中出现的INode
实例的完整形式,因此,如果您只想访问部分值,则需要做的第一件事就是获取实际节点。这可以通过以下几种方式完成:
//Assuming your result row is in a variable r
//With Named Indexing
INode value = r["var"];
//With Indexing
INode value = r[0];
//With method
INode value = r.Value("var");
选择最适合您的用例的一个,一旦您拥有该节点,我们就可以检查它是什么类型的节点并采取相应的行动:
String text;
switch (value.NodeType)
{
case NodeType.Literal:
// Cast to more specific ILiteralNode in order to extract just the text
// excluding the data type or language specifier if present
ILiteralNode lit = (ILiteralNode)value;
text = lit.Value;
break;
case NodeType.Uri:
// Case to more specific IUriNode in order to extract final segment of URI
IUriNode uri = (IUriNode)value;
// Depending on the URI format this might be in the Fragment,
// the last Path Segment or just the URI
text = !String.IsNullOrEmpty(uri.Uri.Fragment) ? uri.Uri.Fragment : (uri.Uri.Segments.Length > 0 ? uri.Uri.Segments[uri.Uri.Segments.Length - 1] : uri.Uri.ToString());
break;
default:
// For anything else default to ToString()
text = value.ToString();
}
// Now do what you want with the text
您可能需要将其封装在可重用的类/方法中,具体取决于您需要调用它的位置和方式。
请注意,如果您将其绑定到GUI应用程序中的某种控件,那么通常有一些方法可以自定义数据的呈现方式,同时保留实际数据。
答案 1 :(得分:0)
我在查询中使用以下内容得到了答案
SELECT?ind(str(?Name)as?name)(str(?Explain)as?explain)(str(?id)as?actid)
WHERE {.....}.