243
243
span.cancast:hover { background-color: #ffa;
244
244
color: black; }
245
245
246
- .SPARQLoperator { background-color: #FFFFbf; /* yellow */
247
- }
246
+ .SPARQLoperator { font-weight: 600; }
248
247
249
248
/* ReSpec */
250
249
dfn { font-style: normal ; }
@@ -4665,6 +4664,7 @@ <h3>Operand Data Types</h3>
4665
4664
<p>SPARQL language extensions may treat additional types as being derived from XML schema
4666
4665
datatypes.</p>
4667
4666
</section>
4667
+
4668
4668
<section id="evaluation">
4669
4669
<h3>Filter Evaluation</h3>
4670
4670
<p>SPARQL provides a subset of the functions and operators defined by
@@ -4826,6 +4826,7 @@ <h4>Effective Boolean Value (EBV)</h4>
4826
4826
with a datatype of <code>xsd:boolean</code> and a lexical value of "false".</p>
4827
4827
</section>
4828
4828
</section>
4829
+
4829
4830
<section id="OperatorMapping">
4830
4831
<h3>Operator Mapping</h3>
4831
4832
<p>The SPARQL grammar identifies a set of operators
@@ -4925,7 +4926,7 @@ <h3>Operator Mapping</h3>
4925
4926
<th colspan="5" class="subHeading" scope="col">Logical Connectives</th>
4926
4927
</tr>
4927
4928
<tr>
4928
- <th>
4929
+ <th><span id="logical-or-operator"/>
4929
4930
<a href="#rConditionalOrExpression" title="ConditionalOrExpression">A <span class="FAOTtoken">||</span> B</a>
4930
4931
</th>
4931
4932
<td>
@@ -4934,7 +4935,7 @@ <h3>Operator Mapping</h3>
4934
4935
<td>
4935
4936
xsd:boolean <a href="#ebv-arg">(EBV)</a>
4936
4937
</td>
4937
- <td class="sparqlOp">
4938
+ <td class="sparqlOp"><span id="logical-and-operator"/>
4938
4939
<a href="#func-logical-or" class="SPARQLoperator">logical-or</a>(A, B)
4939
4940
</td>
4940
4941
<td>xsd:boolean</td>
@@ -5275,32 +5276,91 @@ <h3>Operator Mapping</h3>
5275
5276
<th colspan="5" class="subHeading" scope="col">SPARQL Tests</th>
5276
5277
</tr>
5277
5278
<tr>
5278
- <th>
5279
- <a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a>
5280
- </th>
5279
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
5280
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a></span></td>
5281
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a></span></td>
5282
+ <td>
5283
+ <a href="#func-sameTerm">sameTerm</a>(A, B)
5284
+ </td>
5285
+ <td>xsd:boolean</td>
5286
+ </tr>
5287
+ <tr>
5288
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
5289
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-blank-node">Blank Node</a></span></td>
5290
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-blank-node">Blank Node</a></span></td>
5291
+ <td>
5292
+ <a href="#func-sameTerm">sameTerm</a>(A, B)
5293
+ </td>
5294
+ <td>xsd:boolean</td>
5295
+ </tr>
5296
+ <tr>
5297
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
5298
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
5299
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
5300
+ <td>
5301
+ ( A.subject = B.subject ) <a href="#logical-and-operator" class="SPARQLoperator">&&</a><br/>
5302
+ ( A.predicate = B.predicate ) <a href="#logical-and-operator" class="SPARQLoperator">&&</a><br/>
5303
+ ( A.object = B.object )
5304
+ </td>
5305
+ <td>xsd:boolean</td>
5306
+ </tr>
5307
+ <tr>
5308
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
5309
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a></span></td>
5310
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a></span></td>
5311
+ <td><a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a href="#func-sameTerm">sameTerm</a>(A, B))</td>
5312
+ <td>xsd:boolean</td>
5313
+ </tr>
5314
+ <tr>
5315
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
5316
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-blank-node">Blank Node</a></span></td>
5317
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-blank-node">Blank Node</a></span></td>
5318
+ <td>
5319
+ <a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a href="#func-sameTerm">sameTerm</a>(A, B)
5320
+ </td>
5321
+ <td>xsd:boolean</td>
5322
+ </tr>
5323
+ <tr>
5324
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
5325
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
5326
+ <td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
5327
+ <td>
5328
+ ( A.subject != B.subject ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/>
5329
+ ( A.predicate != B.predicate ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/>
5330
+ ( A.object != B.object )
5331
+ </td>
5332
+ <td>xsd:boolean</td>
5333
+ </tr>
5334
+ <tr>
5335
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">=</span> B</a></th>
5281
5336
<td><span class="type RDFterm">RDF term</span></td>
5282
5337
<td><span class="type RDFterm">RDF term</span></td>
5283
5338
<td class="xpathOp">
5284
- <a href="#func-sameValue" class="SPARQLoperator" >sameValue</a>(A, B)
5285
- </td>
5339
+ <a href="#func-sameValue">sameValue</a>(A, B)
5340
+ </td>
5286
5341
<td>xsd:boolean</td>
5287
5342
</tr>
5288
5343
<tr>
5289
- <th>
5290
- <a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a>
5291
- </th>
5344
+ <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">!=</span> B</a></th>
5292
5345
<td><span class="type RDFterm">RDF term</span></td>
5293
5346
<td><span class="type RDFterm">RDF term</span></td>
5294
5347
<td class="xpathOp">
5295
- <a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a href="#func-sameValue" class="SPARQLoperator" >sameValue</a>(A, B))
5348
+ <a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a href="#func-sameValue">sameValue</a>(A, B))
5296
5349
</td>
5297
5350
<td>xsd:boolean</td>
5298
5351
</tr>
5299
5352
</tbody>
5300
5353
</table>
5301
- <div id="ebv-arg"></div>xsd:boolean function arguments marked with "(EBV)" are
5354
+ <p>
5355
+ <span id="ebv-arg"></span>xsd:boolean function arguments marked with "(EBV)" are
5302
5356
coerced to xsd:boolean by evaluating the <a href="#ebv">effective boolean value of that
5303
5357
argument.</a>
5358
+ </p>
5359
+ <p>
5360
+ Operators <span class="SPARQLoperator">=</span> and <span class="SPARQLoperator">!=</span> applied to
5361
+ <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>
5362
+ apply the operator to each of the components.
5363
+ </p>
5304
5364
<section id="operatorExtensibility">
5305
5365
<h4>Operator Extensibility</h4>
5306
5366
<p>SPARQL language extensions may provide additional associations between operators and
@@ -5314,6 +5374,7 @@ <h4>Operator Extensibility</h4>
5314
5374
BY</code></a> clause.</p>
5315
5375
</section>
5316
5376
</section>
5377
+
5317
5378
<section id="SparqlOps">
5318
5379
<h3>Function Definitions</h3>
5319
5380
<p>This section defines the operators and functions introduced by the SPARQL query language.
@@ -5678,7 +5739,7 @@ <h5>sameTerm</h5>
5678
5739
defined in [[[RDF12-CONCEPTS]]] [[RDF12-CONCEPTS]]; returns FALSE otherwise.</p>
5679
5740
<p>
5680
5741
|term1| and |term2| are the
5681
- <a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF terms </a>
5742
+ <a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">same RDF term </a>
5682
5743
if one of the following is true:
5683
5744
</p>
5684
5745
<ul>
@@ -5756,77 +5817,61 @@ <h5>sameValue</h5>
5756
5817
5757
5818
<p>This function cannot be used directly in expressions. The purpose
5758
5819
of this function is to define the semantics of the "=" operator when applied to
5759
- two RDF terms that do not fall into any of the other, more concrete cases
5820
+ two RDF terms that do not fall into the concrete cases
5760
5821
covered in the operator mapping table in Section
5761
5822
<a href="#OperatorMapping" class="sectionRef"></a>.
5762
5823
</p>
5763
5824
5764
- <p class="ednote" style="background-color: #EEE">
5765
- Revise for triple terms.
5766
- <br/>
5767
- Consider adding non-literal `=` to operator mapping table.
5768
- </p>
5769
-
5770
5825
<p>The result of this function is determined by going through the following steps.</p>
5826
+
5771
5827
<ol>
5772
5828
<li>If <code>term1</code> and <code>term2</code> are
5773
5829
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">equal RDF terms</a>,
5774
- the return TRUE.
5830
+ then return TRUE.
5775
5831
</li>
5776
- <li>If both arguments are literals,
5832
+ <li>If <code>term1</code> or <code>term2</code> is an
5833
+ <a data-cite="RDF12-CONCEPTS#dfn-iri">IRI</a> or a
5834
+ <a data-cite="RDF12-CONCEPTS#dfn-blank-node">blank node</a>
5835
+ then return FALSE.
5836
+ <li>If <code>term1</code> and <code>term2</code> are both
5777
5837
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5778
- and one or both arguments are known to be ill-typed,
5838
+ and one or both of these literals has a datatype that is
5839
+ not handled by the SPARQL processor,
5779
5840
then produce a type error.
5780
5841
</li>
5781
- <li>If <code>term1</code> and <code>term2</code> both
5842
+ <li>If <code>term1</code> and <code>term2</code> are both
5843
+ <a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5844
+ and one or both of these literals are known to be
5845
+ <a data-cite="RDF12-CONCEPTS#dfn-ill-typed">ill-typed</a>,
5846
+ then produce a type error.
5847
+ </li>
5848
+ <li>
5849
+ `"NaN"^^xsd:double` and `"NaN"^^xsd:float` are considered to
5850
+ represent the same value.
5851
+ If <code>term1</code> and <code>term2</code> are
5852
+ both "NaN" for either xsd:double or xsd:float, then
5853
+ return TRUE.
5854
+ </li>
5855
+ <li>If <code>term1</code> and <code>term2</code> are both
5782
5856
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5783
- and the SPARQL processor can determine the values are equal,
5857
+ and the SPARQL processor can determine that their the values are equal,
5784
5858
then return TRUE.
5785
5859
</li>
5786
- <li>If <code>term1</code> and <code>term2</code> both
5860
+ <li>If <code>term1</code> and <code>term2</code> are both
5787
5861
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5788
5862
and the SPARQL processor can determine the values can not be equal,
5789
5863
then return FALSE.
5790
5864
</li>
5791
- <li>Otherwise, return FALSE.
5865
+ <li>
5866
+ If <code>term1</code> and <code>term2</code> are both
5867
+ <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>,
5868
+ apply the function `sameValue` pair-wise to each of the components.
5869
+ Return TRUE if each component pair returns TRUE;
5870
+ produce a type error if any component pair produces an error;
5871
+ otherwise return FALSE.
5792
5872
</li>
5873
+ <li>Otherwise, return FALSE.</li>
5793
5874
</ol>
5794
- <div class="ednote" style="background-color: #EEE">
5795
- <p>
5796
- The treatment of `NaN` can not be consistent with both "same term means same value"
5797
- and "`fn:numeric-equal(NaN, NaN)` is false". So it is an arbitrary choice with
5798
- arguments for all three possible choices.
5799
- For pattern matching, `"NaN"^^xsd:double` must match itself and
5800
- `"NaN"^^xsd:double` does not pattern match `"NaN"^^xsd:float`.
5801
- </p>
5802
- <p>
5803
- The operator mapping for `=` goes to `fn:numeric-compare` which is false.
5804
- The `sameValue` result could be made an error (or false) as a special case.
5805
- </p>
5806
- <p>
5807
- `"NaN"^^xsd:double = "NaN"^^xsd:float` is also handled by the
5808
- operator mapping and is false – `xsd:float` is promoted to `xsd:double`.
5809
- A reading of IEEE 754 is that `"NaN"^^xsd:double` and `"NaN"^^xsd:float`
5810
- are the same term also suggests that `sameValue` is true.
5811
- </p>
5812
- <p>
5813
- <b>Proposal 1</b>: follow "sameTerm means sameValue" and `sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)`
5814
- and `sameValue("NaN"^^xsd:float, "NaN"^^xsd:float)` are <i>true</i>s.
5815
- <br/>
5816
- <b>Proposal 2</b>:
5817
- follow "there is one NaN" so `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is <i>true</i>.
5818
- </p>
5819
- <p>
5820
- Ref</i>: <a href="https://www.w3.org/TR/xmlschema11-2/#dt-specialvalue">XSD schema 1.1 special values</a>
5821
- "are members of the datatype's ·value space·. ". It is not clear whether "special value" literals
5822
- added to the value spaces of `xsd:double` and `xsd:float` are "the same" literals.
5823
- <p>
5824
- <i>Ref</i>: <a href="https://en.wikipedia.org/wiki/IEEE_754#Special_values">(wikipedia) IEEE_754 Special Values</a>
5825
- <i>IEEE 754 specifies a special value called "Not a Number" (NaN)</i>.
5826
- suggests they are the same.
5827
- </p>
5828
- </div>
5829
-
5830
5875
<div id="sameValue-ill-typed" class="note">
5831
5876
<p>A literal is
5832
5877
<a data-cite="RDF12-CONCEPTS#dfn-ill-typed">ill-typed</a>
@@ -5847,31 +5892,19 @@ <h5>sameValue</h5>
5847
5892
The <a href="#OperatorMapping">Operator Mapping</a> for "`=`"
5848
5893
is the function
5849
5894
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">`fn:numeric-equal`</a>
5850
- which returns `false` when comparing arguments involving `NaN`.
5851
- However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true;
5852
- `sameValue` treats "NaN" as the "same value".
5853
- `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:float)` is ` true` .
5895
+ which is defined to return `false` when comparing arguments involving `NaN`.
5896
+ However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true.
5897
+ The function `sameValue` defines `sameValue( "NaN"^^xsd:double, "NaN"^^xsd:double)`
5898
+ to be true because the arguments are the same element of the value space .
5854
5899
</p>
5855
- </div>
5856
- <div id="sameValue-old-name" class="note">
5857
- <p>This function was previously called `RDFterm-equal`.</p>
5858
- </div>
5859
-
5860
- <div class="ednote" style="background-color: #EEE">
5861
5900
<p>
5862
- A SPARQL processor may support datatypes beyond those required.
5863
- Suppose `ex:romanNumeral` is the datatype IRI
5864
- <a href="https://en.wikipedia.org/wiki/Roman_numerals">roman numerals</a>
5865
- which are integer numbers. The SPARQL processor may then be able
5866
- to detemine if two literals have the same value, for example,
5867
- `sameValue(4, "IV"^^ex:romanNumeral)` can then return `true`
5868
- because argument bot represent the value 4.
5869
- For `sameValue("abc"^^xsd:string, "IV"^^ex:romanNumeral)`
5870
- can return `false` because `xsd:string` and `ex:romanNumeral`
5871
- have different value spaces so the arguments can not be the same value.
5901
+ `sameValue` treats the values of `"NaN"^^xsd:double` and `"NaN"^^xsd:float` as being
5902
+ the same. `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`.
5872
5903
</p>
5873
5904
</div>
5874
-
5905
+ <p id="sameValue-zeros" class="note">
5906
+ For xsd:double and xsd:float, `+0`, `-0` and `0` are same value.
5907
+ </p>
5875
5908
<p id="func-sameValue-note1" class="note">
5876
5909
An extended implementation may support additional datatypes for literals. An
5877
5910
implementation processing a query that tests for equivalence of literals with non-recognized datatypes
@@ -5890,22 +5923,6 @@ <h5>sameValue</h5>
5890
5923
<th>sameValue</th>
5891
5924
<th>Results</th>
5892
5925
</tr>
5893
- <tr>
5894
- <td><code>sameValue(2, +2)</code></td>
5895
- <td>true</td>
5896
- </tr>
5897
- <tr>
5898
- <td><code>sameValue(2.0, 2)</code></td>
5899
- <td>true</td>
5900
- </tr>
5901
- <tr>
5902
- <td><code>sameValue(2, "2")</code></td>
5903
- <td>false</td>
5904
- </tr>
5905
- <tr>
5906
- <td><code>sameValue(4, "iv"^^my:romanNumeral)</code></td>
5907
- <td>error, or true by extension</td>
5908
- </tr>
5909
5926
<tr>
5910
5927
<td><code>sameValue(1e10, "NaN"^^xsd:double)</code></td>
5911
5928
<td>false</td>
@@ -5918,9 +5935,16 @@ <h5>sameValue</h5>
5918
5935
<td><code>sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)</code></td>
5919
5936
<td>true</td>
5920
5937
</tr>
5938
+ <tr>
5939
+ <td><code>sameValue( <<(:s :p 123)>> , <<(:s :p 123.0)>> )</td>
5940
+ <td>true</td>
5941
+ </tr>
5921
5942
</tbody>
5922
5943
</table>
5923
5944
</div>
5945
+ <p id="sameValue-old-name" class="note">
5946
+ This function was called `RDFterm-equal` up until SPARQL 1.1.
5947
+ </p>
5924
5948
</section>
5925
5949
5926
5950
<section id="func-isIRI">
0 commit comments