Re: Clarification of variable scoping

David,

The working group has decided to add a pair of tests based on your 
example to the SPARQL 1.1 test suite.

test: 
http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bind/manifest#bind10

query: http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bind/bind10.rq

test: 
http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bind/manifest#bind11

query: http://www.w3.org/2009/sparql/docs/tests/data-sparql11/bind/bind11.rq

The tests use a nested group graph pattern so as to remove a dependency 
on GRAPH.

PREFIX : <http://example.org/>

SELECT ?s ?v ?z
{
   BIND(4 AS ?z)
   {
     # ?z is not in-scope at the time of filter execution.
     ?s :p ?v . FILTER(?v = ?z)
   }
}

Result:

-------------
| s | v | z |
=============
-------------

and

PREFIX : <http://example.org/>

SELECT ?s ?v ?z
{
   BIND(4 AS ?z)
   # ?z is in scope at the time of filter execution.
   ?s :p ?v .
   FILTER(?v = ?z)
}

Result:

---------------
| s   | v | z |
===============
| :s4 | 4 | 4 |
---------------

We would be grateful if you would acknowledge that your comment has been 
answered by sending a reply to this mailing list.

     Andy, on behalf of the SPARQL WG

Received on Tuesday, 6 December 2011 16:59:50 UTC