2017-10-02 1 views
1

이 리소스 내에서 모든 트리플을 삭제해야하는 SPARQL 쿼리를 작성하고 있습니다.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 . 

나는 시도했다 : 필터는 특정 주제와 지정하기 때문에 그것은 꽤 분명하다

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

:

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

그러나, ID가 그 안에 빈 노드를 삭제하지 않습니다 공백 노드에는 해당 제목이 없습니다.

빈 노드를 어떻게 삭제할 수 있습니까?

답변

0

중첩 된 빈 노드가 없기를 바랍니다. 이것을 시도하십시오 :

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.