8

SPARQL の有効なUPDATE ステートメントをドキュメント (W3C、名人、セマンティック Web ページ、または独自のカスタム コードなど) で指摘できる人はいますか?

WHERE の指定と、単一のクエリで更新される複数のトリプルで完了する必要があります。

ありがとう。

編集/例:

これが私の現在のコードです。これは、 の現在のすべての値を、INSERT 句で指定された値に置き換えることを目的dc:creatorとしていますdc:titledc:descriptionこのクエリは、ロジックと構文の両方で正しいですか?

WITH GRAPH  <http://127.0.0.1:3000/dendro_graph>  
DELETE 
{ 
  :teste  dc:creator      ?o0 .
  :teste  dc:title        ?o1 .
  :teste  dc:description  ?o2 .
}
INSERT 
{ 
  :teste  dc:creator      "Creator%201" .
  :teste  dc:creator      "Creator%202" .
  :teste  dc:title        "Title%201" .
  :teste  dc:description  "Description%201" .
} 
WHERE 
{ 
  :teste  dc:creator      ?o0 .
  :teste  dc:title        ?o1 .
  :teste  dc:description  ?o2 .
} 
4

4 に答える 4

18

あなたが何を達成しようとしているのか、なぜあなたが提供する更新例があなたが望むことをしていないのかはまだ完全にはわかりませんが、目的が特定の主題のトリプルを置き換える更新をすることである場合は、何かをすることができますこのような:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/> 

DELETE {?s ?p ?o}
INSERT {?s ex:title "foo" ;
           ex:description "bar" ;
           rdf:type ex:FooBar .  
       }
WHERE  { ?s ?p ?o . 
         FILTER (?s = ex:subject1) 
}

上記の操作によりex:subject1、サブジェクトとしての既存のトリプルがすべて削除され、新しいタイトル、説明、およびタイプが挿入されます。

または、フィルターが気に入らない場合は、上記を次のように定式化することもできます。

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/> 

DELETE {ex:subject1 ?p ?o}
INSERT {ex:subject1 ex:title "foo" ;
                    ex:description "bar" ;
                    rdf:type ex:FooBar .  
}
WHERE  { 
        ex:subject1 ?p ?o . 
}

特定のサブジェクトの特定のプロパティのみを削除する場合 (そのサブジェクトのすべてのトリプルではなく)、次のように操作を変更できます。

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix ex: <http://example.org/> 

DELETE {ex:subject1 ex:title ?t ;
                    ex:description ?d ; 
                    rdf:type ?c . 
       }
INSERT {ex:subject1 ex:title "foo" ;
                    ex:description "bar" ;
                    rdf:type ex:FooBar .  
}
WHERE  { 
        ex:subject1 ex:title ?t ;
                    ex:description ?d ;
                    rdf:type ?c . 
}
于 2013-10-22T11:56:54.057 に答える
5

SPARQL では、更新は DELETE とそれに続く INSERT として表されます。

http://www.w3.org/TR/2010/WD-sparql11-update-20100126/#t413

PREFIX foaf:  <http://xmlns.com/foaf/0.1/>

WITH <http://example/addresses>
DELETE { ?person foaf:firstName 'Bill' }
INSERT { ?person foaf:firstName 'William' }
WHERE
  { ?person a foaf:Person .
    ?person foaf:firstName 'Bill'
  }
于 2013-10-21T19:09:09.407 に答える
2

ハレルヤ、神に感謝します。

壁に頭をぶつけた3日後、回避策のような解決策があると思います。最初にDELETEステートメントを作成し、セミコロンを使用して挿入するトリプルを指定します。まだ 2 つの操作がありますが、少なくともクエリ サーバーによって制御されます。つまり、2 つの別々の要求を実行する必要はありませDELETEUPDATE

これが私の作業コードです。現在(明らかに)修正されています:

WITH GRAPH  <http://127.0.0.1:3000/dendro_graph>  
DELETE 
{ 
  :teste  dc:creator  ?o0 .
  :teste  dc:title    ?o1 .
} 
WHERE 
{ 
  :teste  dc:creator  ?o0 .
  :teste  dc:title    ?o1 .
}; 

<------最初の部分の最後にあるセミコロンに注意してください

INSERT DATA
{ 
  :teste   dc:creator   "criador%20do%20teste"  .
  :teste   dc:creator   "second%20criador%20do%20teste"  .
  :teste   dc:creator   "third%20criador%20do%20teste"  .
  :teste   dc:creator   "fourth%20criador%20do%20teste"  .
  :teste   dc:title     "t1"  .
  :teste   dc:title     "t3"  .
  :teste   dc:title     "second%20title"  .
}
于 2013-10-21T19:55:33.930 に答える
-3

sparql の挿入はできません。すでにマッピングされている rdf ファイルをダンプするための sparql の処理。リンクされたデータまたはグラフ データに対する唯一のクエリ処理です。mysql、sql などのデータベースではありません。

主語オブジェクト述語形式の rdf ファイル。

select * where{?s ?p ?o の sparql クエリ。}結果を得る

于 2016-02-11T10:26:03.803 に答える