@@ -5739,7 +5739,7 @@ <h5>sameTerm</h5>
5739
5739
defined in [[[RDF12-CONCEPTS]]] [[RDF12-CONCEPTS]]; returns FALSE otherwise.</p>
5740
5740
<p>
5741
5741
|term1| and |term2| are the
5742
- <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>
5743
5743
if one of the following is true:
5744
5744
</p>
5745
5745
<ul>
@@ -5822,72 +5822,50 @@ <h5>sameValue</h5>
5822
5822
<a href="#OperatorMapping" class="sectionRef"></a>.
5823
5823
</p>
5824
5824
5825
- <p class="ednote" style="background-color: #EEE">
5826
- Revise for triple terms.
5827
- <br/>
5828
- Consider adding non-literal `=` to operator mapping table.
5829
- </p>
5830
-
5831
5825
<p>The result of this function is determined by going through the following steps.</p>
5826
+
5832
5827
<ol>
5833
5828
<li>If <code>term1</code> and <code>term2</code> are
5834
5829
<a data-cite="RDF12-CONCEPTS#dfn-rdf-term-equality">equal RDF terms</a>,
5835
- the return TRUE.
5830
+ then return TRUE.
5836
5831
</li>
5837
- <li>If both arguments are literals,
5832
+ <li>If <code>term1</code> and <code>term2</code> are both
5838
5833
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5839
- and one or both arguments are known to be ill-typed,
5834
+ and one or both of these literals are known to be
5835
+ <a data-cite="RDF12-CONCEPTS#dfn-ill-typed">ill-typed</a>,
5840
5836
then produce a type error.
5841
5837
</li>
5842
- <li>If <code>term1</code> and <code>term2</code> both
5838
+ <li>
5839
+ "NaN"^^xsd:double and "NaN"^^xsd:float are considered to
5840
+ represent the same value.
5841
+ If <code>term1</code> and <code>term2</code> are
5842
+ both "NaN" for either xsd:double or xsd:float then
5843
+ return TRUE.
5844
+ </li>
5845
+ <li>
5846
+ For xsd:double and xsd:float, `+0`, `-0` and `0` are same value.
5847
+ If <code>term1</code> and <code>term2</code> each
5848
+ have datatype IRI xsd:double or xsd:float and
5849
+ a lexical form of one of these zeros, then return TRUE.
5850
+ </li>
5851
+ <li>If <code>term1</code> and <code>term2</code> are both
5843
5852
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5844
- and the SPARQL processor can determine the values are equal,
5853
+ and the SPARQL processor can determine that their the values are equal,
5845
5854
then return TRUE.
5846
5855
</li>
5847
- <li>If <code>term1</code> and <code>term2</code> both
5856
+ <li>If <code>term1</code> and <code>term2</code> are both
5848
5857
<a data-cite="RDF12-CONCEPTS#dfn-literal">literals</a>
5849
5858
and the SPARQL processor can determine the values can not be equal,
5850
5859
then return FALSE.
5851
5860
</li>
5852
- <li>Otherwise, return FALSE.
5861
+ <li>
5862
+ If <code>term1</code> and <code>term2</code> are both
5863
+ <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>,
5864
+ apply the function `sameValue` pair-wise to each of the components.
5865
+ Return TRUE if each component pair returns TRUE, otherise return FALSE.
5853
5866
</li>
5867
+ <li>Otherwise, return FALSE.</li>
5854
5868
</ol>
5855
- <div class="ednote" style="background-color: #EEE">
5856
- <p>
5857
- The treatment of `NaN` can not be consistent with both "same term means same value"
5858
- and "`fn:numeric-equal(NaN, NaN)` is false". So it is an arbitrary choice with
5859
- arguments for all three possible choices.
5860
- For pattern matching, `"NaN"^^xsd:double` must match itself and
5861
- `"NaN"^^xsd:double` does not pattern match `"NaN"^^xsd:float`.
5862
- </p>
5863
- <p>
5864
- The operator mapping for `=` goes to `fn:numeric-compare` which is false.
5865
- The `sameValue` result could be made an error (or false) as a special case.
5866
- </p>
5867
- <p>
5868
- `"NaN"^^xsd:double = "NaN"^^xsd:float` is also handled by the
5869
- operator mapping and is false – `xsd:float` is promoted to `xsd:double`.
5870
- A reading of IEEE 754 is that `"NaN"^^xsd:double` and `"NaN"^^xsd:float`
5871
- are the same term also suggests that `sameValue` is true.
5872
- </p>
5873
- <p>
5874
- <b>Proposal 1</b>: follow "sameTerm means sameValue" and `sameValue("NaN"^^xsd:double, "NaN"^^xsd:double)`
5875
- and `sameValue("NaN"^^xsd:float, "NaN"^^xsd:float)` are <i>true</i>s.
5876
- <br/>
5877
- <b>Proposal 2</b>:
5878
- follow "there is one NaN" so `sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)` is <i>true</i>.
5879
- </p>
5880
- <p>
5881
- Ref</i>: <a href="https://www.w3.org/TR/xmlschema11-2/#dt-specialvalue">XSD schema 1.1 special values</a>
5882
- "are members of the datatype's ·value space·. ". It is not clear whether "special value" literals
5883
- added to the value spaces of `xsd:double` and `xsd:float` are "the same" literals.
5884
- <p>
5885
- <i>Ref</i>: <a href="https://en.wikipedia.org/wiki/IEEE_754#Special_values">(wikipedia) IEEE_754 Special Values</a>
5886
- <i>IEEE 754 specifies a special value called "Not a Number" (NaN)</i>.
5887
- suggests they are the same.
5888
- </p>
5889
- </div>
5890
-
5891
5869
<div id="sameValue-ill-typed" class="note">
5892
5870
<p>A literal is
5893
5871
<a data-cite="RDF12-CONCEPTS#dfn-ill-typed">ill-typed</a>
@@ -5910,29 +5888,17 @@ <h5>sameValue</h5>
5910
5888
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">`fn:numeric-equal`</a>
5911
5889
which returns `false` when comparing arguments involving `NaN`.
5912
5890
However, `sameTerm("NaN"^^xsd:double, "NaN"^^xsd:double)` is true;
5913
- `sameValue` treats "NaN" as the "same value".
5891
+ `sameValue` treats "NaN"^^xsd:double as the "same value".
5892
+ </p>
5893
+ <p>
5894
+
5895
+ `sameValue` treats "NaN"^^xsd:double and "NaN"^^xsd:float as the same value.
5914
5896
`sameTerm("NaN"^^xsd:double, "NaN"^^xsd:float)` is `true`.
5915
5897
</p>
5916
5898
</div>
5917
5899
<div id="sameValue-old-name" class="note">
5918
5900
<p>This function was previously called `RDFterm-equal`.</p>
5919
5901
</div>
5920
-
5921
- <div class="ednote" style="background-color: #EEE">
5922
- <p>
5923
- A SPARQL processor may support datatypes beyond those required.
5924
- Suppose `ex:romanNumeral` is the datatype IRI
5925
- <a href="https://en.wikipedia.org/wiki/Roman_numerals">roman numerals</a>
5926
- which are integer numbers. The SPARQL processor may then be able
5927
- to detemine if two literals have the same value, for example,
5928
- `sameValue(4, "IV"^^ex:romanNumeral)` can then return `true`
5929
- because argument bot represent the value 4.
5930
- For `sameValue("abc"^^xsd:string, "IV"^^ex:romanNumeral)`
5931
- can return `false` because `xsd:string` and `ex:romanNumeral`
5932
- have different value spaces so the arguments can not be the same value.
5933
- </p>
5934
- </div>
5935
-
5936
5902
<p id="func-sameValue-note1" class="note">
5937
5903
An extended implementation may support additional datatypes for literals. An
5938
5904
implementation processing a query that tests for equivalence of literals with non-recognized datatypes
@@ -5951,22 +5917,6 @@ <h5>sameValue</h5>
5951
5917
<th>sameValue</th>
5952
5918
<th>Results</th>
5953
5919
</tr>
5954
- <tr>
5955
- <td><code>sameValue(2, +2)</code></td>
5956
- <td>true</td>
5957
- </tr>
5958
- <tr>
5959
- <td><code>sameValue(2.0, 2)</code></td>
5960
- <td>true</td>
5961
- </tr>
5962
- <tr>
5963
- <td><code>sameValue(2, "2")</code></td>
5964
- <td>false</td>
5965
- </tr>
5966
- <tr>
5967
- <td><code>sameValue(4, "iv"^^my:romanNumeral)</code></td>
5968
- <td>error, or true by extension</td>
5969
- </tr>
5970
5920
<tr>
5971
5921
<td><code>sameValue(1e10, "NaN"^^xsd:double)</code></td>
5972
5922
<td>false</td>
@@ -5979,6 +5929,10 @@ <h5>sameValue</h5>
5979
5929
<td><code>sameValue("NaN"^^xsd:double, "NaN"^^xsd:float)</code></td>
5980
5930
<td>true</td>
5981
5931
</tr>
5932
+ <tr>
5933
+ <td><code>sameValue( <<(:s :p 123)>> , <<(:s :p 123.0)>> )</td>
5934
+ <td>true</td>
5935
+ </tr>
5982
5936
</tbody>
5983
5937
</table>
5984
5938
</div>
0 commit comments