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

Maxence Guesdon Maxence.Guesdon at inria.fr
Tue Feb 21 03:27:20 EST 2012


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/




More information about the redland-dev mailing list