CommentResponse:DM-1

From SPARQL Working Group
Jump to: navigation, search
I'm starting to look at property paths in SPARQL 1.1, and the spec doesn't make it clear how/whether reversal "distributes" over other operators. Suppose you have the triples

y  a  o1
o1 b  x

y  b  o2
o2  a  x

in the database. Would {  x   ^(a/b)   y  } match with the first pair, or with the second pair of triples in the database?

David - section "9.1 Property Path Syntax" has list giving the precedence rules of the property path syntax forms. Groups using () has higher precedence than unary ^ which in turn is higher precedence than binary operator /

{ x ^(a/b) y } is the reverse path of a/b so "(reverse (seq :a :b))" so it matches the first case, reversing the whole of a/b. i.e. b then a

---- data
@prefix :        <http://www.example.org/> .

:y1  :a  :o1 .
:o1 :b  :x1 .

:y2  :b  :o2 .
:o2  :a  :x2 .
---- query
PREFIX :	<http://www.example.org/>

SELECT *
{  ?x   ^(:a/:b)   ?y  }
---- results
-------------
| x   | y   |
=============
| :x1 | :y1 |
-------------

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)