SPARQL:在插入查询中指定数据类型

SPARQL:在插入查询中指定数据类型,sparql,rdf,Sparql,Rdf,我想通过SPARQL查询将这些三元组添加到我的图中 <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:my="http://example.com/ontology#"> <rdf:Description rdf:about="http:/example.com/entity/thisEntity">

我想通过SPARQL查询将这些三元组添加到我的图中

<?xml version="1.0"?>

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:my="http://example.com/ontology#">

<rdf:Description rdf:about="http:/example.com/entity/thisEntity">
    <rdf:type rdf:resource="http://example.com/ontology#Identification" />
    <my:someID rdf:datatype="http://www.w3.org/2001/XMLSchema#string">003</my:someID>
    <my:hasSource  rdf:resource="http:/example.com/entity/thisSource" />
  </rdf:Description>

</rdf:RDF>

003
如何指定第三个三元组的数据类型

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX my: <http://example.com/ontology#>

INSERT DATA {
              <http:/example.com/entity/thisEntity> rdf:type <http://example.com/ontology#Identification>;
                                                 my:hasSource  <http:/example.com/entity/thisSource>;
                                                 my:someID "003"@xsd:string.

            }
前缀rdf:
前缀“我的”:
插入数据{
rdf:类型;
我的:hasSource;
my:someID“003”@xsd:string。
}

你就快到了。
@
用于语言标记。数据类型是通过使用
^
分隔符附加的。所以使用
“003”^^xsd:string

您还需要将名称空间前缀添加到更新中:

PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
前缀xsd:
顺便提一下:在RDF 1.1中,
xsd:string
是任何没有明确定义的数据类型或语言标记的文本的默认数据类型。所以
“003”
“003”^^xsd:string
都是相同的字符串类型的文本