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

David Brooks d.brooks at auckland.ac.nz
Tue Feb 21 03:52:48 EST 2012


Hi Maxence,

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.


Regards,
Dave



On 21/02/12 9:27 PM, Maxence Guesdon wrote:
> Hello,
>
> I have a problem when using the result of a CONSTRUCT query. I do not know
> if the behaviour I get is the one expected according to the sparql
> definition (I did not find this case in [1]).
>
> I execute the following query:
> (I know that<http://foo>  is not a correct uri, it is just to make my
> example shorter in this message)
>
> CONSTRUCT {
>    <http://subject>  <http://predicate>  ?seq .
>    ?seq ?seq_index ?uri .
>    ?uri<http://resource>  ?uri2
>    }
> WHERE
>    {<http://subject>  <http://predicate>  ?seq .
>      ?seq ?seq_index ?uri
>      OPTIONAL { ?uri<http://resource>  ?uri2 }
>    }
>
> In my model,
>    ?seq will match a blank node and
>    ?seq_index will match rdf:_N nodes.
>    ?uri can match an uri or a blank node, for I have in my model
>    ...<rdf:_N>  <uri>
> but sometimes
>    ...<rdf:_N>  _:foo
> _:foo<http://listOf>  <uri>
>
> When I execute this query on my model, in the resulting triples, ?seq is
> bound to a *new* blank node, not the original blank node of my model. I
> thought blank nodes would be introduced in the result triples only if I
> used blank node syntax (like [], _:foo and so on). But it appears that
> fresh blank nodes are also introduced when a variable is bound to a blank
> node of the model.
>
> For example, I was expecting to have the triple
>    <http://subject>  <http://predicate>  _:r1329810294r9040r2
> but instead I get
>    <http://subject>  <http://predicate>  _:r1_r1329810294r9040r2
>
> Is this the expected behaviour ?
>
> Regards,
>
> Maxence
>
> [1] http://www.w3.org/TR/rdf-sparql-query/
>
>
> _______________________________________________
> redland-dev mailing list
> redland-dev at lists.librdf.org
> http://lists.librdf.org/mailman/listinfo/redland-dev


More information about the redland-dev mailing list