- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Wed, 2 Feb 2005 18:34:20 -0000
- To: "Alberto Reggiori" <alberto@asemantics.com>, "RDF Data Access Working Group" <public-rdf-dawg@w3.org>
-------- Original Message -------- > From: Alberto Reggiori <> > Date: 2 February 2005 11:23 > > hi all, > > I have small question about an example I came up to test grouping > > Given the following data: > > <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> > "SPARQL Tutorial" . > <http://example.org/book/book1> <http://example.org/ns#price> > "42"^^<http://www.w3.org/2001/XMLSchema#integer> . > <http://example.org/book/book2> <http://purl.org/dc/elements/1.1/title> > "The Semantic Web" . > <http://example.org/book/book2> <http://example.org/ns#price> > "23"^^<http://www.w3.org/2001/XMLSchema#integer> . > > is the following query > > PREFIX dc: <http://purl.org/dc/elements/1.1/> > PREFIX ns: <http://example.org/ns#> > SELECT ?title ?price > WHERE > { > ( ?x dc:title ?title ) > ( ?x ns:price ?price ) > } > AND ( ( ?price < 30 ) || ( ?price > 40 ) ) > > going to fail accordingly to what stated in > > http://www.w3.org/2001/sw/DataAccess/rq23/#CombiningPatterns > > ? > > I think so - due the above query has two graph-patterns, and that the > constraints by definition do not bind any var - it should fail It should be OK - what about #CombiningPatterns is suggesting this to you? { ( ?x dc:title ?title ) ( ?x ns:price ?price ) } is a group of patterns that just generates bindings for ?title and ?price these go into the cosntraint. Variables are NOT scoped by blocks - they are global to the query. Is this the reading you are making? There is an outer group containing this inner group (redundantly) and the AND clause. The AND applies to the outer group "all solutions are such that ?price < 30 || ? price > 40" The example in that section shows that the query can include {} nesting and return the same solutions. Suggestions for improvement? > > While the following query would succeed > > PREFIX dc: <http://purl.org/dc/elements/1.1/> > PREFIX ns: <http://example.org/ns#> > SELECT ?title ?price > WHERE > ( ?x ns:price ?price ) > { > ( ?x dc:title ?title ) > } > AND ( ( ?price < 30 ) || ( ?price > 40 ) ) > > due that the first (top most) graph-pattern binds ?x and ?price > accordingly > > In other words, in the implementation, while processing the blocks > stack one should execute any "binding graph-pattern" first or fail if > not possible. Not sure about "stack" given that variables are in a flat global space. The order issue is a separate matter - I have been working on a generalisation of the optional variables rule that also covers constraints to get consistent answers. I have an action item to report the ordering and optionals issue. The rule has to be that for constraints, if a variable is used elsewhere, that part is executed first. This naturally follows from the declarative interpretation. More soon :-) Andy > > is this the correct behavior? > > thanks > > Alberto > > - > Alberto Reggiori, @Semantics S.R.L. > www.asemantics.com
Received on Wednesday, 2 February 2005 18:34:53 UTC