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

Maxence Guesdon Maxence.Guesdon at inria.fr
Thu Feb 23 03:03:21 EST 2012


On Thu, 23 Feb 2012 12:42:34 +1300
David Brooks <d.brooks at auckland.ac.nz> wrote:

> 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> ] ;
>        ] .
> 

Thanks for your answer.

This output does not show the *way* it works, since we cannot see if
blank node identifiers in the results have the same identifiers as blank
nodes in the input graph.

Here is attached a script doing the same with rdfproc. It shows that blank
nodes identifiers are different in the original graph and in the
CONSTRUCT-ed graph.

So, what I would like to known, and I dit not find in the RDF docs is:
what do I get when I use a ?var pattern to match a blank node.

In librdf, I get a blank node with a new identifier, even though I did not
used the syntax introducing new blank nodes. My first thought was that I
should have got a blank node with the same identifier but it does not seem
so.

But in fact, when I use a select query to retrieve the statements I
want to delete (since I had no success with the sparql DELETE query), I can
use librdf_model_remove_statement with each statement found and... it works.
And I don't really know why.

I know there is no magic in computers, so if anybody can enlighten me on
how it works...

Regards,

Maxence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test2.sh
Type: application/x-shellscript
Size: 1279 bytes
Desc: not available
URL: <http://lists.librdf.org/pipermail/redland-dev/attachments/20120223/3e0bb228/attachment.bin>


More information about the redland-dev mailing list