簡體   English   中英

SPARQL查詢以刪除資源中的所有空白節點

[英]SPARQL Query to delete all blank nodes with in a Resource

我正在編寫一個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 ] 

這很明顯,因為過濾器指定了一個特定的主題,而空白節點沒有該主題。

知道如何刪除空白節點嗎?

我希望您沒有嵌套的空白節點。 嘗試這個:

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從本體中刪除空白節點

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM