2017-03-15 12 views
1

SPARQL INSERTステートメントを使用して新しいインスタンスを自分のオントロジーに挿入したいとします。 サンプルインスタンス:SPARQLを使用してOWLオントロジーに新しいインスタンスを挿入する方法

<owl:NamedIndividual rdf:about="http://www.test123.com/test123-ontology.owl#cap_123"> 
<rdf:type rdf:resource="http://www.test123.com/test123-ontology.owl#HealthBeauty"/> 
<description>Test test test</description> 
<hasPrice rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">49</hasPrice> 
<id rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">123</id> 
</owl:NamedIndividual> 

挿入されるべき新しいインスタンスは次の属性があります。

id: 456 
hasPrice: 15 
description: "Test2 test2 test2" 

私は、クエリのINSERTの一部を完了させる方法がわからない:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX owl: <http://www.test123.com/test123-ontology.owl#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
PREFIX oo: <http://www.w3.org/2002/07/owl#> 
INSERT " 
{ 
//... 
} 
+0

これはW3Cの仕様書にはっきりと記載されています:https://www.w3.org/TR/sparql11-update/#insertData – AKSW

+0

@AKSW:この部分を指定する方法がわかりません 'rdf:type rdf:resource = "http://www.test123.com/test123-ontology.owl#HealthBeauty" /> ' – Dinosaurius

+0

私は分かりません。すべてがトリプルなので、単純に ' rdf:type 。 – AKSW

答えて

2

解決策は次のとおりです。

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX owl: <http://www.test123.com/test123-ontology.owl#> 
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> 
PREFIX oo: <http://www.w3.org/2002/07/owl#> 

INSERT 
{ 
    owl:cap_456 rdf:type owl:HealthBeauty . 
    owl:cap_456 owl:id 456 . 
    owl:cap_456 owl:hasPrice 15 . 
    owl:cap_456 owl:description 'Test2 test2 test2' . } 
WHERE 
{ 
    FILTER NOT EXISTS 
    { 
    owl:cap_456 rdf:type owl:HealthBeauty . 
    } 
} 
+0

なぜ私は以前のコメントで言及したように 'WHERE'節が必要なのか、単に' INSERT DATA'を使わなかったのか分かりません。トリプルパターンはありません。変数はありません。トリプルだけです。 'WHERE'節は、データ内のパターンをマッチングするためのものです – AKSW

関連する問題