[redland-dev] Problem or misunderstanding with CONSTRUCT and blank nodes

David Brooks d.brooks at auckland.ac.nz
Wed Feb 22 18:42:34 EST 2012


Hmm, I will pass on this one, as I'm learning as I go and don't know the 
answer to the question "Is there some way to use SPARQL to delete 
statements that include a blank node?".

Back to your original question about CONSTRUCT though, this does work 
for me. Taking the graph:

    @base <http://example.org/uris/> .
    @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
    @prefix ex: <http://example.org/terms#> .

    <s1> <p1> [
       a rdf:Seq ;
       rdf:_1 <u1> ;
       rdf:_2 [ ex:list <u2> ] ;
       ] .

    <s2> <p1> [
       a rdf:Seq ;
       rdf:_1 <u1> ;
       rdf:_2 [ ex:list <u2> ] ;
       ] .

then the SPARQL:

    base <http://example.org/uris/>
    prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    prefix ex: <http://example.org/terms#>

    CONSTRUCT {
    <s1> <p1> ?seq .
       ?seq ?seq_index ?uri .
       ?uri ex:list ?uri2
       }
    WHERE
       { <s1> <p1> ?seq .
         ?seq ?seq_index ?uri
         OPTIONAL { ?uri ex:list ?uri2 }
       }

will (using roqet) return the sub-graph:

    <s1> <p1> [
       a rdf:Seq ;
       rdf:_1 <u1> ;
       rdf:_2 [ ex:list <u2> ] ;
       ] .


Best regards,
Dave

On 23/02/12 6:24 AM, Maxence Guesdon wrote:
> On Wed, 22 Feb 2012 10:28:52 +1300
> David Brooks<d.brooks at auckland.ac.nz>  wrote:
>
>> I would use "DELETE WHERE { ... }" -- see
>> http://www.w3.org/TR/sparql11-update/#deleteInsert.
> Hello,
>
> I just tried to to that, with no success.
> If I try:
>
> DELETE {<http://subject>  <http://pred>  ?seq .
>           ?seq ?seq_index ?uri .
>           ?uri<http://listOf>  ?uri2
>     }
> WHERE
>     <http://subject>  <http://pred>  ?seq .
>     ?seq ?seq_index ?uri
>     OPTIONAL { ?uri<listOf>  ?uri2 }
>
> With the same model as in my previous message, ?seq, ?seq_index and
> sometimes ?uri match blank nodes. I thought these variables would refer to
> the original blank nodes, so that they would be removed. But it does not
> seem to be the case.
>
> http://www.w3.org/TR/sparql11-update/#deleteInsert states that
>    "Blank nodes are prohibited in a DELETE template, since using a new blank
>     node in a DELETE template would lead to nothing being deleted, as a new
>     blank node cannot match anything in the Graph Store."
>
> So it seems like it behaves like with the construct template.
>
> So, is it impossible to delete blank nodes with such delete queries ?
>
> Regards,
>
> Maxence
>
>> Regards,
>> Dave
>>
>> On 22/02/12 12:29 AM, Maxence Guesdon wrote:
>>> On Tue, 21 Feb 2012 21:52:48 +1300
>>> David Brooks<d.brooks at auckland.ac.nz>   wrote:
>>>
>>>> Hi Maxence,
>>> Hello,
>>>
>>>> Blank nodes are anonymous -- the nodes without labels in a visual graph
>>>> of your model.
>>>>
>>>> In an RDF store these nodes are given identifiers in order to include
>>>> the nodes in statements. The actual value of a blank node's identifier
>>>> though is local to the graph it is part of. Generating another graph via
>>>> a query is very likely to assign different values, and even two
>>>> identical queries against the same graph are likely to return different
>>>> blank node identifiers.
>>> Thanks for your answer. So that's a feature.
>>>
>>> The reason why I encountered this problem is that I wanted to remove a part
>>> of my model. So this query was supposed to return the statements to remove
>>> from my model.
>>>
>>> I have to do it another way. For information, since I have no experience
>>> yet of performing such an operation, what is your favorite way of removing
>>> part of your model when it contains blank nodes ? I mean, the less painful
>>> one, of cource :-)
>>>
>>> Regards,
>>>
>>> Maxence
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.librdf.org/pipermail/redland-dev/attachments/20120223/af2b5a4c/attachment.html>


More information about the redland-dev mailing list