【问题标题】:SPARQL Query to delete all blank nodes with in a ResourceSPARQL 查询以删除资源中的所有空白节点
【发布时间】:2018-03-13 13:19:36
【问题描述】:

我正在编写一个 SPARQL 查询,该查询应该删除此资源中的所有三元组。

prefix oslc: <http://open-services.net/ns/core#>
prefix example: <http://rdf.company.com/ns/something/net#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix dcterms: <http://purl.org/dc/terms/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

example:Resource2
        a                oslc:ResourceShape ;
        oslc:describes   example:Resource2 ;
        oslc:property    [ a                      oslc:Property ;
                           oslc:isMemberProperty  true ;
                           oslc:name              "pgn" ;
                           oslc:occurs            oslc:Zero-or-one ;
                           oslc:valueType         xsd:integer ] ;
        dcterms:title    "Resource2"^^rdf:XMLLiteral .   

我试过了:

 DELETE
    { ?s  ?p   ?o } 
  WHERE 
    { 
      ?s  ?p   ?o .
      FILTER  ( ?s IN ( <http://rdf.company.com/ns/something/net#Resource2>))
    }

但是,id 不会删除其中的空白节点:

[ a                      oslc:Property ;
  oslc:isMemberProperty  true ;
  oslc:name              "pgn" ;
  oslc:occurs            oslc:Zero-or-one ;
  oslc:valueType         xsd:integer ] 

这很明显,因为过滤器指定了一个特定的主题,而空白节点没有那个主题。

知道如何删除空白节点吗?

【问题讨论】:

    标签: sparql rdf turtle-rdf blank-nodes


    【解决方案1】:

    我希望你没有嵌套的空白节点。试试这个:

    PREFIX example: <http://rdf.company.com/ns/something/net#>
    
    DELETE {
        ?s  ?p   ?o .
        ?o  ?p1  ?o1 .
    }
    WHERE {
        VALUES (?s) { (example:Resource2) }
        ?s  ?p  ?o .
        OPTIONAL {
            ?o  ?p1  ?o1  .
            FILTER (isBlank(?o)) 
        }
    }
    

    相关问题:Delete blank node from ontology through SPARQL UPDATE

    【讨论】:

      猜你喜欢
      • 2017-04-12
      • 2017-10-22
      • 1970-01-01
      • 2017-10-11
      • 2016-03-14
      • 2014-03-16
      • 2017-11-03
      • 1970-01-01
      • 2012-04-04
      相关资源
      最近更新 更多