我正在尝试使用 INSERT WHERE 插入值。我使用 4Store 作为语义存储库。
查询如下,
INSERT {
<http://some.com#test2> rdf:type <http://dbpedia.org/ontology/Floor> .
?URI1257846444363706 <http://dbpedia.org/ontology/TestFloor> <http:// some.com #test2> .
<http:// some.com #test2> <http://dbpedia.org/ontology/floorNo> 'B11' .
}
WHERE {
?URI1257846444278864 rdf:type <http://dbpedia.org/ontology/Campus> .
?URI1257846444278864 <http://dbpedia.org/ontology/hasCampusCode> 'ABC' .
?URI1257846444363706 rdf:type <http://dbpedia.org/ontology/Building> .
?URI1257846444278864 <http://dbpedia.org/ontology/Building> ?URI1257846444363706 .
?URI1257846444363706 <http://dbpedia.org/ontology/hasBuildingCode> 'XYZ' .
}
当我运行上述查询时,INSERT 中的三元组没有插入到存储中(我尝试使用 SELECT 查询检索三元组,但它不返回任何结果)。我已经检查了 WHERE 子句中的所有三元组,并且它们都存在于商店中。
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT * {
?URI1257846444278864 rdf:type <http://dbpedia.org/ontology/Campus> .
?URI1257846444278864 <http://dbpedia.org/ontology/hasCampusCode> 'ABC' .
?URI1257846444363706 rdf:type <http://dbpedia.org/ontology/Building> .
?URI1257846444278864 <http://dbpedia.org/ontology/Building> ?URI1257846444363706 .
?URI1257846444363706 <http://dbpedia.org/ontology/hasBuildingCode> 'XYZ' .
}
结果:
<head>
<variable name="URI1257846444278864"/>
<variable name="URI1257846444363706"/>
</head>
<results>
<result>
<binding name="URI1257846444278864"><uri>http://some.com/Ontology/2012.owl#ranfa1087b9-6cee-4433-a4d3-816e9b1af208</uri></binding>
<binding name="URI1257846444363706"><uri>http://some.com/Ontology/2012.owl#ran1224548700931885</uri></binding>
</result>
</results>
但是只有一个变量的相同 INSERT WHERE 工作正常,
INSERT {
<http://some.com#test2> rdf:type <http://dbpedia.org/ontology/Floor> .
?URI1257846444363706 <http://dbpedia.org/ontology/TestFloor> <http:// some.com #test2> .
<http:// some.com #test2> <http://dbpedia.org/ontology/floorNo> 'B11' .
}
WHERE {
?URI1257846444363706 rdf:type <http://dbpedia.org/ontology/Building> .
?URI1257846444363706 <http://dbpedia.org/ontology/hasBuildingCode> 'XYZ' .
}
第一个 INSERT WHERE 有什么问题吗?