Re: matching literals in SPARQL

On 11/11/14 05:26, Peter F. Patel-Schneider wrote:
> I have been looking over the SPARQL 1.1 documents and have been trying
> to figure out a simple question about literal matching.
>
> The question is whether basic graph pattern matching is sensitive to the
> surface form of literals in an RDF graph.
>
> For example, does the basic graph pattern
>    ex:a ex:b "01"^^xsd:integer .
> match the RDF graph
>    ex:a ex:b "1"^^xsd:integer .
>
> It appears to me that it does not, but I would like confirmation of this.

You are correct, it does not. BGP matching is defined as matching when 
two RDF terms are the same (see 
http://www.w3.org/TR/sparql11-query/#BasicGraphPattern ):

  "Here, μ1(v) = μ2(v) means that μ1(v) and μ2(v) are the same RDF term."

This notion of "the same RDF term" is not explicitly linked to a 
definition from this particular spot, but the applicable notions of term 
equality are defined in the RDF Concepts & Abstract Syntax (C&AS) 
document, and in several other places in the SPARQL spec it is made 
explicit that those definitions apply (in particular, in the definitions 
of RDFterm-equal and sameTerm).

In your particular example, Literal term equality applies, which is 
defined in section 3.3 of C&AS:

   "Literal term equality: Two literals are term-equal (the same RDF
    literal) if and only if the two lexical forms, the two datatype
    IRIs, and the two language tags (if any) compare equal, character by
    character. Thus, two literals can have the same value without being
    the same RDF term. For example:

       "1"^^xs:integer
       "01"^^xs:integer

    denote the same value, but are not the same literal RDF terms and
    are not term-equal because their lexical form differs."


Cheers,

Jeen

Received on Monday, 10 November 2014 23:46:56 UTC