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 @@
SPARQL language extensions may treat additional types as being derived from XML schema datatypes.
+SPARQL provides a subset of the functions and operators defined by @@ -4825,6 +4826,7 @@
xsd:boolean
and a lexical value of "false".
The SPARQL grammar identifies a set of operators @@ -4924,7 +4926,7 @@
+ 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. +
SPARQL language extensions may provide additional associations between operators and @@ -5313,6 +5374,7 @@
This section defines the operators and functions introduced by the SPARQL query language. @@ -5669,248 +5731,222 @@
- 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:
-term1
and term2
are equal RDF terms, as defined below.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.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
+ IRIs that are the
+ same as IRIs.
term1
and term2
are
+ literals that are
+ equal as literal terms.
+ term1
and term2
are
+ blank nodes that are
+ equal as blank nodes.
+ term1
and term2
are
+ triple terms that are
+ equal as triple terms; that
+ is, the
+ subject,
+ predicate, and
+ object components are pair-wise
+ the same term.
+ 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 | +
+ 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.
+ +term1
and term2
are
+ equal RDF terms,
+ then return TRUE.
+ term1
or term2
is an
+ IRI or a
+ blank node
+ then return FALSE.
+ 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.
+ term1
and term2
are both
+ literals
+ and one or both of these literals are known to be
+ ill-typed,
+ then produce a type error.
term1
and term2
are
+ both "NaN" for either xsd:double or xsd:float, then
+ return TRUE.
+ term1
and term2
are both
+ literals
+ and the SPARQL processor can determine that their the values are equal,
+ then return TRUE.
+ term1
and term2
are both
+ literals
+ and the SPARQL processor can determine the values can not be equal,
+ then return FALSE.
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.
+
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:
-name1 | -name2 | -
---|---|
"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:
+sameValue | +Results | +
---|---|
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. +
-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:
-name1 | -name2 | -
---|---|
"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)) -} --
aLabel | -bLabel | -
---|---|
"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.
@@ -5963,6 +5999,7 @@isIRI
xsd:boolean isBLANK (RDF term term)@@ -7212,12 +7249,12 @@