SPARQL - 查询没有上层属性的所有数据属性
SPARQL - Query all data properties without upper-level-properties
我想查询特定个人的所有数据属性。
我的数据属性定义在Ontology
在我的 ontology 中,我定义了数据属性树。
要查询的目标个体
我的目标个体在我的 owl 中定义如下:
<owl:NamedIndividual rdf:about="http://www.owl.de/ontology/i40component-01#I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest">
<rdf:type rdf:resource="http://www.owl.de/ontology/i40component-01#Manifest"/>
<decription rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example work cell.</decription>
<ele rdf:datatype="http://www.w3.org/2001/XMLSchema#string">35.0</ele>
<lat rdf:datatype="http://www.w3.org/2001/XMLSchema#string">52.518611</lat>
<lon rdf:datatype="http://www.w3.org/2001/XMLSchema#string">13.376111</lon>
<name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">I40 Work Cell 1</name>
<production_date rdf:datatype="http://www.w3.org/2001/XMLSchema#string">2012-12-31T23:57:00</production_date>
<uuid rdf:datatype="http://www.w3.org/2001/XMLSchema#string">e41bdfaa-7163-46ed-8cb3-350fa226bbaf</uuid>
</owl:NamedIndividual>
在 Protege 中它看起来像:
目标结果
goal/aim 是查询 Protege 或 OWL 片段中显示的所有已定义数据属性。此查询的预期结果应为:
----------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
==========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
----------------------------------------------------------------------------------------------------------------------------------------------------------
我当前的 SPARQL 查询和结果
我目前的测试方法如下所示。它构建并执行 SPARQL 查询。
@Test
public void showDataPropertiesOfWholeManifest() {
SelectBuilder sb = new SelectBuilder() //Building a Query template
.addPrefix("i40comp", owl.getI40NameSpace() + "#")
.addPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
.addPrefix("xsd", "http://www.w3.org/2001/XMLSchema#")
.addPrefix("owl", "http://www.w3.org/2002/07/owl#")
.addPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
//Define Variables
sb.addVar("?I40Component");
sb.addVar("?dataProperty");
sb.addVar("?datatypeValue");
//Find Individuals for Type "Manifest"
sb.addWhere("?I40Component", "rdf:type", URI.generateSparqlURI(I40VOC.Classes.AssetAdministrationShell.Manifest));
//Find Individual with UUID "e41bdfaa-7163-46ed-8cb3-350fa226bbaf"
sb.addWhere("?I40Component", "i40comp:uuid", "e41bdfaa-7163-46ed-8cb3-350fa226bbaf"); //Filter I40Component
//Get all properties of this individual
sb.addWhere("?dataProperty", "?", "owl:DatatypeProperty");
// Results preparation
sb.addWhere("?I40Component", "?dataProperty", "?datatypeValue");
//Filters blanks and literals
try {
sb.addFilter("!isBlank(?datatypeValue)");
sb.addFilter("isLiteral(?datatypeValue)");
} catch (ParseException e) {
e.printStackTrace();
}
//Build query and print result
Query q = sb.build();
executeSPARQLqueryAndPrintResult(q);
}
或再次作为查询字符串:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX i40comp: <http://www.owl.de/ontology/i40component-01#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?I40Component ?dataProperty ?datatypeValue
WHERE
{ ?I40Component
rdf:type i40comp:Manifest ;
i40comp:uuid "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" .
?dataProperty
? owl:DatatypeProperty .
?I40Component
?dataProperty ?datatypeValue
FILTER ( ! isBlank(?datatypeValue) )
FILTER isLiteral(?datatypeValue)
}
很遗憾,结果不是我需要的结果。查看以下结果:
----------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
==========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "13.376111" |
----------------------------------------------------------------------------------------------------------------------------------------------------------
SPARQL 查询以某种方式转到 "upper level data properties" 和 select 它们作为结果并打印真实子 属性 的值。
喜欢:
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "52.518611" |
正常应该是:
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
也许你们中的一位可以向我解释为什么会发生这种情况,并且还可以支持我改进查询以获得目标结果。
解决方案
所需的提示来自 AKSW:
what is wrong with query result? I mean, it's obviously due to
inference. So my guess - and you didn't show the type of model you
used - you're using an inference model. Am I right? Do you know what
inference aka reasoning is? I you only want the asserted data the
simplest case is to use a default model and load the data into this
one – AKSW
问题是在 Jena 中使用推理模型(推理又名推理):
OntModel mONT = ModelFactory.createOntologyModel();
此类模型也会提供干扰数据。
为了只获取我场景中的断言数据,最简单的方法是使用默认模型而不是 Ontology 模型(Model
而不是 OntModel
) :
Model mONT = ModelFactory.createDefaultModel()
通过此更改,我仅获得断言数据和目标结果:
---------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
=========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
---------------------------------------------------------------------------------------------------------------------------------------------------------
谢谢 AKSW!
我想查询特定个人的所有数据属性。
我的数据属性定义在Ontology
在我的 ontology 中,我定义了数据属性树。
要查询的目标个体
我的目标个体在我的 owl 中定义如下:
<owl:NamedIndividual rdf:about="http://www.owl.de/ontology/i40component-01#I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest">
<rdf:type rdf:resource="http://www.owl.de/ontology/i40component-01#Manifest"/>
<decription rdf:datatype="http://www.w3.org/2001/XMLSchema#string">An example work cell.</decription>
<ele rdf:datatype="http://www.w3.org/2001/XMLSchema#string">35.0</ele>
<lat rdf:datatype="http://www.w3.org/2001/XMLSchema#string">52.518611</lat>
<lon rdf:datatype="http://www.w3.org/2001/XMLSchema#string">13.376111</lon>
<name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">I40 Work Cell 1</name>
<production_date rdf:datatype="http://www.w3.org/2001/XMLSchema#string">2012-12-31T23:57:00</production_date>
<uuid rdf:datatype="http://www.w3.org/2001/XMLSchema#string">e41bdfaa-7163-46ed-8cb3-350fa226bbaf</uuid>
</owl:NamedIndividual>
在 Protege 中它看起来像:
目标结果
goal/aim 是查询 Protege 或 OWL 片段中显示的所有已定义数据属性。此查询的预期结果应为:
----------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
==========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
----------------------------------------------------------------------------------------------------------------------------------------------------------
我当前的 SPARQL 查询和结果
我目前的测试方法如下所示。它构建并执行 SPARQL 查询。
@Test
public void showDataPropertiesOfWholeManifest() {
SelectBuilder sb = new SelectBuilder() //Building a Query template
.addPrefix("i40comp", owl.getI40NameSpace() + "#")
.addPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#")
.addPrefix("xsd", "http://www.w3.org/2001/XMLSchema#")
.addPrefix("owl", "http://www.w3.org/2002/07/owl#")
.addPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
//Define Variables
sb.addVar("?I40Component");
sb.addVar("?dataProperty");
sb.addVar("?datatypeValue");
//Find Individuals for Type "Manifest"
sb.addWhere("?I40Component", "rdf:type", URI.generateSparqlURI(I40VOC.Classes.AssetAdministrationShell.Manifest));
//Find Individual with UUID "e41bdfaa-7163-46ed-8cb3-350fa226bbaf"
sb.addWhere("?I40Component", "i40comp:uuid", "e41bdfaa-7163-46ed-8cb3-350fa226bbaf"); //Filter I40Component
//Get all properties of this individual
sb.addWhere("?dataProperty", "?", "owl:DatatypeProperty");
// Results preparation
sb.addWhere("?I40Component", "?dataProperty", "?datatypeValue");
//Filters blanks and literals
try {
sb.addFilter("!isBlank(?datatypeValue)");
sb.addFilter("isLiteral(?datatypeValue)");
} catch (ParseException e) {
e.printStackTrace();
}
//Build query and print result
Query q = sb.build();
executeSPARQLqueryAndPrintResult(q);
}
或再次作为查询字符串:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX i40comp: <http://www.owl.de/ontology/i40component-01#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?I40Component ?dataProperty ?datatypeValue
WHERE
{ ?I40Component
rdf:type i40comp:Manifest ;
i40comp:uuid "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" .
?dataProperty
? owl:DatatypeProperty .
?I40Component
?dataProperty ?datatypeValue
FILTER ( ! isBlank(?datatypeValue) )
FILTER isLiteral(?datatypeValue)
}
很遗憾,结果不是我需要的结果。查看以下结果:
----------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
==========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:aas | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:manifest | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "52.518611" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "13.376111" |
----------------------------------------------------------------------------------------------------------------------------------------------------------
SPARQL 查询以某种方式转到 "upper level data properties" 和 select 它们作为结果并打印真实子 属性 的值。 喜欢:
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:wpt_gps_location | "52.518611" |
正常应该是:
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
也许你们中的一位可以向我解释为什么会发生这种情况,并且还可以支持我改进查询以获得目标结果。
解决方案
所需的提示来自 AKSW:
what is wrong with query result? I mean, it's obviously due to inference. So my guess - and you didn't show the type of model you used - you're using an inference model. Am I right? Do you know what inference aka reasoning is? I you only want the asserted data the simplest case is to use a default model and load the data into this one – AKSW
问题是在 Jena 中使用推理模型(推理又名推理):
OntModel mONT = ModelFactory.createOntologyModel();
此类模型也会提供干扰数据。
为了只获取我场景中的断言数据,最简单的方法是使用默认模型而不是 Ontology 模型(Model
而不是 OntModel
) :
Model mONT = ModelFactory.createDefaultModel()
通过此更改,我仅获得断言数据和目标结果:
---------------------------------------------------------------------------------------------------------------------------------------------------------
| I40Component | dataProperty | datatypeValue |
=========================================================================================================================================================
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lon | "13.376111" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:ele | "35.0" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:decription | "An example work cell." |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:name | "I40 Work Cell 1" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:production_date | "2012-12-31T23:57:00" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:uuid | "e41bdfaa-7163-46ed-8cb3-350fa226bbaf" |
| i40comp:I40Component_e41bdfaa-7163-46ed-8cb3-350fa226bbaf_I40WorkCell1_AASmanifest | i40comp:lat | "52.518611" |
---------------------------------------------------------------------------------------------------------------------------------------------------------
谢谢 AKSW!