CommentResponse:HS-1

From SPARQL Working Group
Jump to: navigation, search

Hi Hong,

The key issues is how a variable is handled when it is not matched in the first OPTIONAL clause, and used a second time in a later OPTIONAL clause. This is part of SPARQL 1.0 and has not changed in SPARQL 1.1.

In SPARQL, there is no "NULL" and an unmatched variable is not simply not bound to any value and is available to be bound in a later clause.

A pattern such as:

{ 
  ?x a foaf:Person .
  OPTIONAL { ?x foaf:name ?name }
  OPTIONAL { ?x vcard:FN ?name }
}

will bind name to the value for foaf:name, and only the value for vcard:FN if it was not found in the first OPTIONAL. This provides a way to access optional information preferentially.

In your second query, the results you are receiving from ARQ are the correct results. The Working Group produces detailed test suites to help implementers create multiple interoperable implementations of the SPARQL language. If you find that a particular implementation does not behave in a way you expect, you might consider contacting the implementer to determine why.

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

Lee On behalf of the SPARQL WG