diff --git a/spec/index.html b/spec/index.html index 7d1e8e2..c9cbb58 100644 --- a/spec/index.html +++ b/spec/index.html @@ -243,8 +243,7 @@ span.cancast:hover { background-color: #ffa; color: black; } -.SPARQLoperator { background-color: #FFFFbf; /* yellow */ - } +.SPARQLoperator { font-weight: 600; } /* ReSpec */ dfn { font-style: normal ; } @@ -511,7 +510,8 @@

Terminology

language tag
  • - base direction + + base direction
  • datatype IRI @@ -4664,6 +4664,7 @@

    Operand Data Types

    SPARQL language extensions may treat additional types as being derived from XML schema datatypes.

    +

    Filter Evaluation

    SPARQL provides a subset of the functions and operators defined by @@ -4825,6 +4826,7 @@

    Effective Boolean Value (EBV)

    with a datatype of xsd:boolean and a lexical value of "false".

    +

    Operator Mapping

    The SPARQL grammar identifies a set of operators @@ -4924,7 +4926,7 @@

    Operator Mapping

    Logical Connectives - + A || B @@ -4933,7 +4935,7 @@

    Operator Mapping

    xsd:boolean (EBV) - + logical-or(A, B) xsd:boolean @@ -5274,32 +5276,91 @@

    Operator Mapping

    SPARQL Tests - - A = B - + A = B + IRI + IRI + + sameTerm(A, B) + + xsd:boolean + + + A = B + Blank Node + Blank Node + + sameTerm(A, B) + + xsd:boolean + + + A = B + Triple Term + Triple Term + + ( A.subject = B.subject ) &&
    + ( A.predicate = B.predicate ) &&
    + ( A.object = B.object ) + + xsd:boolean + + + A != B + IRI + IRI + fn:not(sameTerm(A, B)) + xsd:boolean + + + A != B + Blank Node + Blank Node + + fn:not(sameTerm(A, B) + + xsd:boolean + + + A != B + Triple Term + Triple Term + + ( A.subject != B.subject ) ||
    + ( A.predicate != B.predicate ) ||
    + ( A.object != B.object ) + + xsd:boolean + + + A = B RDF term RDF term - RDFterm-equal(A, B) - + sameValue(A, B) + xsd:boolean - - A != B - + A != B RDF term RDF term - fn:not(RDFterm-equal(A, B)) + fn:not(sameValue(A, B)) xsd:boolean -
    xsd:boolean function arguments marked with "(EBV)" are +

    + xsd:boolean function arguments marked with "(EBV)" are coerced to xsd:boolean by evaluating the effective boolean value of that argument. +

    +

    + Operators = and != applied to + triple terms + apply the operator to each of the components. +

    Operator Extensibility

    SPARQL language extensions may provide additional associations between operators and @@ -5313,6 +5374,7 @@

    Operator Extensibility

    BY clause.

    +

    Function Definitions

    This section defines the operators and functions introduced by the SPARQL query language. @@ -5669,248 +5731,222 @@

    NOT IN

    Functions on RDF Terms

    -
    -
    RDFterm-equal
    -
    -              xsd:boolean RDFterm-equal (RDF term term1, RDF term term2)
    -            
    -

    This function cannot be used directly in expressions. The purpose of this function is to define the semantics of the "=" operator when applied to two RDF terms that do not fall into any of the other, more concrete cases covered in the operator mapping table in Section .

    -

    The function is defined as follows:

    -
      -
    • Returns TRUE if term1 and term2 are equal RDF terms, as defined below.
    • -
    • Produces a type error if term1 and term2 are both literals having the - same datatype IRI; this datatype IRI is not in the - set of recognized datatype IRIs; and the - lexical forms of the two literals are different from one another.
    • -
    • Returns FALSE otherwise.
    • -
    + +
    +
    sameTerm
    +
     xsd:boolean  sameTerm (RDF term term1, RDF term term2)
    +

    Returns TRUE if term1 and term2 are the same RDF term as + defined in [[[RDF12-CONCEPTS]]] [[RDF12-CONCEPTS]]; returns FALSE otherwise.

    - term1 and term2 are equal RDF terms if any of the following is - true:

    + |term1| and |term2| are the + same RDF term + if one of the following is true: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    sameTerm(<http://example/>, <http://example/>)true
    sameTerm(<http://example/>, <https://example/>)false
    sameTerm("abc", "abc")true
    sameTerm("abc"@en, "abc")false
    sameTerm("abc"@en, "abc"@EN)true
    sameTerm("abc"@en--rtl, "abc"@en)false
    sameTerm(2, 2.0)false
    sameTerm(2, "2"^^xsd:integer)true
    sameTerm(2, "02"^^xsd:integer)false
    +
    + +
    +
    + +
    sameValue
    +
    +              xsd:boolean sameValue (RDF term term1, RDF term term2)
    +            
    + +

    This function cannot be used directly in expressions. The purpose + of this function is to define the semantics of the "=" operator when applied to + two RDF terms that do not fall into the concrete cases + covered in the operator mapping table in Section + . +

    + +

    The result of this function is determined by going through the following steps.

    + +
      +
    1. If term1 and term2 are + equal RDF terms, + then return TRUE. +
    2. +
    3. If term1 or term2 is an + IRI or a + blank node + then return FALSE. +
    4. If term1 and term2 are both + literals + and one or both of these literals has a datatype that is + not handled by the SPARQL processor, + then produce a type error. +
    5. +
    6. If term1 and term2 are both + literals + and one or both of these literals are known to be + ill-typed, + then produce a type error.
    7. - term1 is a literal and - term2 is a literal - such that the datatype IRI - of each of these two literals is in the set of - recognized datatype IRIs - and both literals have the same literal value. + `"NaN"^^xsd:double` and `"NaN"^^xsd:float` are considered to + represent the same value. + If term1 and term2 are + both "NaN" for either xsd:double or xsd:float, then + return TRUE. +
    8. +
    9. If term1 and term2 are both + literals + and the SPARQL processor can determine that their the values are equal, + then return TRUE. +
    10. +
    11. If term1 and term2 are both + literals + and the SPARQL processor can determine the values can not be equal, + then return FALSE.
    12. - term1 and term2 are the same - blank node. + If term1 and term2 are both + triple terms, + apply the function `sameValue` pair-wise to each of the components. + Return TRUE if each component pair returns TRUE; + produce a type error if any component pair produces an error; + otherwise return FALSE.
    13. - -

      +

    14. Otherwise, return FALSE.
    15. +
    +
    +

    A literal is + ill-typed + if its datatype is handled by the SPARQL processor and + its lexical form is not in the + lexical space + of the datatype. +

    +

    + If the two arguments are literals, the function `sameValue` + returns `true` or `false` in cases where the SPARQL processor + can determine that the values of these literals are equal or are not equal. + If the SPARQL processor can not be sure, it returns `error`. +

    +
    +
    +

    + The Operator Mapping for "`=`" + is the function + `fn:numeric-equal` + which is defined to return `false` when comparing arguments involving `NaN`. + However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true. + The function `sameValue` defines `sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)` + to be true because the arguments are the same element of the value space. +

    +

    + `sameValue` treats the values of `"NaN"^^xsd:double` and `"NaN"^^xsd:float` as being + the same. `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`. +

    +
    +

    + For xsd:double and xsd:float, `+0`, `-0` and `0` are same value. +

    +

    An extended implementation may support additional datatypes for literals. An implementation processing a query that tests for equivalence of literals with non-recognized datatypes (and non-identical lexical form and datatype IRI) returns an error, indicating that it is unable to determine whether or not the values of the compared literals are equivalent. For example, an unextended implementation will produce an error when testing either "iiii"^^my:romanNumeral = "iv"^^my:romanNumeral or "iiii"^^my:romanNumeral != - "iv"^^my:romanNumeral.

    -
    -
    -PREFIX foaf:       <http://xmlns.com/foaf/0.1/>
    -
    -_:a  foaf:name       "Alice".
    -_:a  foaf:mbox       <mailto:alice@work.example> .
    -
    -_:b  foaf:name       "Ms A.".
    -_:b  foaf:mbox       <mailto:alice@work.example> .
    -              
    -
    -

    This query finds the people who have multiple foaf:name triples:

    -
    -PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    -SELECT ?name1 ?name2
    -WHERE {
    -    ?x foaf:name  ?name1 ;
    -       foaf:mbox  ?mbox1 .
    -    ?y foaf:name  ?name2 ;
    -       foaf:mbox  ?mbox2 .
    -    FILTER (?mbox1 = ?mbox2 && ?name1 != ?name2)
    -}
    -

    Query result:

    -
    - - - - - - - - - - - - - - - -
    name1name2
    "Alice""Ms A."
    "Ms A.""Alice"
    -
    -
    -
    -

    In this query for documents that were annotated at a specific date and time (New - Year's Day 2005, measures in timezone +00:00), the RDF terms are not the same, but have - equivalent values according to their datatype:

    -
    -
    -PREFIX a:          <http://www.w3.org/2000/10/annotation-ns#>
    -PREFIX dc:         <http://purl.org/dc/elements/1.1/>
    -
    -_:b   a:annotates   <http://www.w3.org/TR/rdf-sparql-query/> .
    -_:b   dc:date       "2004-12-31T19:00:00-05:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
    -
    -
    -PREFIX a:      <http://www.w3.org/2000/10/annotation-ns#>
    -PREFIX dc:     <http://purl.org/dc/elements/1.1/>
    -PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
    +                  "iv"^^my:romanNumeral.
    +            

    -SELECT ?annotates -WHERE { - ?annot a:annotates ?annotates . - ?annot dc:date ?date . - FILTER ( ?date = xsd:dateTime("2005-01-01T00:00:00Z") ) -} -
    -
    - - - - - - - - - -
    annotates
    <http://www.w3.org/TR/rdf-sparql-query/>
    -
    -
    +

    Examples:

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    sameValueResults
    sameValue(1e10, "NaN"^^xsd:double)false
    sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)true
    sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)true
    sameValue( <<(:s :p 123)>> , <<(:s :p 123.0)>> )true
    +

    + This function was called `RDFterm-equal` up until SPARQL 1.1. +

    -
    -
    sameTerm
    -
     xsd:boolean  sameTerm (RDF term term1, RDF term term2)
    -

    Returns TRUE if term1 and term2 are the same RDF term as - defined in [[[RDF12-CONCEPTS]]] [[RDF12-CONCEPTS]]; returns FALSE otherwise.

    -
    -
    -PREFIX foaf:       <http://xmlns.com/foaf/0.1/>
     
    -_:a  foaf:name       "Alice".
    -_:a  foaf:mbox       <mailto:alice@work.example> .
    -
    -_:b  foaf:name       "Ms A.".
    -_:b  foaf:mbox       <mailto:alice@work.example> .
    -              
    -
    -

    This query finds the people who have multiple foaf:name triples:

    -
    -PREFIX foaf: <http://xmlns.com/foaf/0.1/>
    -SELECT ?name1 ?name2
    -WHERE {
    -    ?x foaf:name  ?name1 ;
    -       foaf:mbox  ?mbox1 .
    -    ?y foaf:name  ?name2 ;
    -       foaf:mbox  ?mbox2 .
    -    FILTER (sameTerm(?mbox1, ?mbox2) && !sameTerm(?name1, ?name2))
    -}
    -                
    -

    Query result:

    -
    - - - - - - - - - - - - - - - -
    name1name2
    "Alice""Ms A."
    "Ms A.""Alice"
    -
    -
    -
    -

    Unlike RDFterm-equal, sameTerm can be used to test for non-equivalent typed literals with unsupported datatypes:

    -
    -
    -PREFIX :          <http://example.org/WMterms#>
    -PREFIX t:         <http://example.org/types#>
    -
    -_:c1  :label        "Container 1" .
    -_:c1  :weight       "100"^^t:kilos .
    -_:c1  :displacement  "100"^^t:liters .
    -
    -_:c2  :label        "Container 2" .
    -_:c2  :weight       "100"^^t:kilos .
    -_:c2  :displacement  "85"^^t:liters .
    -
    -_:c3  :label        "Container 3" .
    -_:c3  :weight       "85"^^t:kilos .
    -_:c3  :displacement  "85"^^t:liters .
    -              
    -
    -
    -PREFIX  :      <http://example.org/WMterms#>
    -PREFIX  t:     <http://example.org/types#>
    -
    -SELECT ?aLabel1 ?bLabel
    -WHERE { 
    -   ?a  :label        ?aLabel .
    -   ?a  :weight       ?aWeight .
    -   ?a  :displacement ?aDisp .
    -
    -   ?b  :label        ?bLabel .
    -   ?b  :weight       ?bWeight .
    -   ?b  :displacement ?bDisp .
    -
    -   FILTER ( sameTerm(?aWeight, ?bWeight) && !sameTerm(?aDisp, ?bDisp)) 
    -}
    -                
    -
    - - - - - - - - - - - - - - - -
    aLabelbLabel
    "Container 1""Container 2"
    "Container 2""Container 1"
    -
    -
    -
    -

    The test for boxes with the same weight may also be done with the '=' operator - (RDFterm-equal) as the test for - "100"^^t:kilos = "85"^^t:kilos will result in an error, eliminating that - potential solution.

    -
    isIRI
    @@ -5963,6 +5999,7 @@ 
    isIRI
    +
    isBLANK
     xsd:boolean  isBLANK (RDF term term)
    @@ -7212,12 +7249,12 @@
    CONCAT
    fn:concat function. If all input literals are literals with the same language tag - and same base direction + and same base direction then the returned string literal is a literal with that language tag and base direction. If all input literals are literals with the same language tag, - but not all the same base direction, + but not all the same base direction, the returned literal is a literal with that language tag and no base direction.

    @@ -12240,7 +12277,7 @@

    Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language

    base direction: `LANGDIR`, `hasLANG`, hasLANGDIR, and `STRLANGDIR`
  • Define parser input as being an - RDF string. + RDF string. Exclude Unicode surrogates from Unicode escape sequences.
  • Remove concepts of plain and simple literals, in favor of explicit mentions of `xsd:string`
  • Migrate XML Schema references to 1.1
  • @@ -12250,10 +12287,10 @@

    Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language

  • Editorial changes: