【问题标题】:SPARQL: Specify datatype in INSERT querySPARQL:在 INSERT 查询中指定数据类型
【发布时间】:2018-01-10 00:19:12
【问题描述】:

同样,我想通过 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>

我应该如何指定第三个三元组的数据类型?

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.

            }

【问题讨论】:

    标签: sparql rdf


    【解决方案1】:

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

    您还需要在更新中添加命名空间前缀:

    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    

    顺便说一句:在 RDF 1.1 中,xsd:string 是任何没有明确定义的数据类型或语言标记的文字的默认数据类型。所以"003""003"^^xsd:string 都是相同的字符串类型的文字。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多