SPARQL查询以删除资源中的所有空白节点 [英] SPARQL Query to delete all blank nodes with in a Resource

查看:103
本文介绍了SPARQL查询以删除资源中的所有空白节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am writing a SPARQL query that should delete all triples within in this resource.

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不会删除其中的空白节点:

However, id does not delete the blank node within it:

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

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

It is pretty obvious because the filter specifies a specific subject and the blank node does not have that subject.

有什么想法我也要删除空白节点吗?

Any idea how can I delete the blank node as well?

推荐答案

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

I hope you do not have nested blank nodes. Try this:

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)) 
    }
}

相关问题:通过SPARQL UPDATE从本体中删除空白节点.

这篇关于SPARQL查询以删除资源中的所有空白节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆