Skip to content
107 changes: 100 additions & 7 deletions spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3674,7 +3674,7 @@ <h3>ORDER BY</h3>
<p>The <a href="#op_lt">"&lt;" operator</a> (see the <a href="#OperatorMapping">Operator
Mapping</a> and <a href="#operatorExtensibility">17.3.1 Operator Extensibility</a>) defines
the relative order of pairs of <code>numerics</code>,
<code>xsd:strings</code>, <code>xsd:booleans</code> and <code>xsd:dateTimes</code>. Pairs of
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making source more readable. A little manual tidy.

Suggested change
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of
<code>xsd:strings</code>, <code>xsd:booleans</code>, <code>xsd:dateTimes</code>, and
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>. Pairs of

IRIs are ordered by comparing them as literals with datatype <code>xsd:string</code>.</p>
<p>SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be
ordered:</p>
Expand All @@ -3683,6 +3683,7 @@ <h3>ORDER BY</h3>
<li>Blank nodes</li>
<li>IRIs</li>
<li>RDF literals</li>
<li>Triple terms</li>
</ol>
<p>SPARQL does not define a total ordering of all possible RDF terms. Here are a few examples
of pairs of terms for which the relative order is undefined:</p>
Expand Down Expand Up @@ -5418,9 +5419,7 @@ <h3>Operator Mapping</h3>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
( A.subject = B.subject ) <a href="#logical-and-operator" class="SPARQLoperator">&amp;&amp;</a><br/>
( A.predicate = B.predicate ) <a href="#logical-and-operator" class="SPARQLoperator">&amp;&amp;</a><br/>
( A.object = B.object )
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), 0)
</td>
<td>xsd:boolean</td>
</tr>
Expand All @@ -5445,9 +5444,7 @@ <h3>Operator Mapping</h3>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
( A.subject != B.subject ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/>
( A.predicate != B.predicate ) <a href="#logical-or-operator" class="SPARQLoperator">||</a><br/>
( A.object != B.object )
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), 0))
</td>
<td>xsd:boolean</td>
</tr>
Expand All @@ -5469,6 +5466,42 @@ <h3>Operator Mapping</h3>
</td>
<td>xsd:boolean</td>
</tr>
<tr>
<th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;</span> B</a></th>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), -1)
</td>
<td>xsd:boolean</td>
</tr>
<tr>
<th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&lt;=</span> B</a></th>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), 1))
</td>
<td>xsd:boolean</td>
</tr>
<tr>
<th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;</span> B</a></th>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), 1)
</td>
<td>xsd:boolean</td>
</tr>
<tr>
<th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">&gt;=</span> B</a></th>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td><span class="type RDFterm"><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Term</a></span></td>
<td>
<a data-cite="XPATH-FUNCTIONS-31#func-not">fn:not</a>(<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-sameTerm">compareTripleTerm</a>(A, B), -1))
</td>
<td>xsd:boolean</td>
</tr>
</tbody>
</table>
<p>
Expand Down Expand Up @@ -6084,6 +6117,66 @@ <h5>sameValue</h5>
</p>
</section>

<section id="func-compareTripleTerm">
<h5>compareTripleTerm</h5>
<pre class="prototype nohighlight">
<span class="return">xsd:integer</span> <span class="operator" style="text-transform: none;">compareTripleTerm</span> (<span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term1</span>, <span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term2</span>)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making source more readable. A little manual tidy.

Suggested change
<span class="return">xsd:integer</span> <span class="operator" style="text-transform: none;">compareTripleTerm</span> (<span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term1</span>, <span class="type"><span class="type RDFterm">Triple term</span></span> <span class="name">term2</span>)
<span class="return">xsd:integer</span>
<span class="operator" style="text-transform: none;">compareTripleTerm</span>
(<span class="type"><span class="type RDFterm">Triple term</span></span>
<span class="name">term1</span>,
<span class="type"><span class="type RDFterm">Triple term</span></span>
<span class="name">term2</span>)

</pre>

<p>This function cannot be used directly in expressions. The purpose
of this function is to define the semantics of value-comparison operators on <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a> such as "=" and "&lt;" operator
in Section <a href="#OperatorMapping" class="sectionRef"></a>.
</p>

<p>This function returns -1, 0, 1, or throws an error.
Comparison is performed pairwise on the components of the triple terms in the order subject, predicate, object until the result is determined.
Comment on lines +6128 to +6129
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making source more readable. A little manual tidy.

Suggested change
<p>This function returns -1, 0, 1, or throws an error.
Comparison is performed pairwise on the components of the triple terms in the order subject, predicate, object until the result is determined.
<p>This function returns `-1`, `0`, or `1`, or throws an error.
Comparison is performed pairwise on the components of the triple terms
in the order subject, predicate, object until the result is determined.

An error is thrown if comparing two components results in an error.</p>

<p>The result of this function is determined by going through the following steps.</p>

<ol>
<li>If <code>SUBJECT(A) = SUBJECT(B)</code> evaluates to true, go to the next step.
If <code>SUBJECT(A) &lt; SUBJECT(B)</code> evaluates to true, return -1.
If <code>SUBJECT(A) &gt; SUBJECT(B)</code> evaluates to true, return 1.
If any of the evalutions cause an error, raise an error.
</li>
<li>If <code>PREDICATE(A) = PREDICATE(B)</code> evaluates to true, go to the next step.
If <code>PREDICATE(A) &lt; PREDICATE(B)</code> evaluates to true, return -1.
If <code>PREDICATE(A) &gt; PREDICATE(B)</code> evaluates to true, return 1.
If any of the evalutions cause an error, raise an error.
</li>
<li>If <code>OBJECT(A) = OBJECT(B)</code> evaluates to true, return 0.
If <code>OBJECT(A) &lt; OBJECT(B)</code> evaluates to true, return -1.
If <code>OBJECT(A) &gt; OBJECT(B)</code> evaluates to true, return 1.
If any of the evalutions cause an error, raise an error.
</li>
</ol>

<p>Examples:</p>
<div class="result">
<table>
<tbody>
<tr>
<th>compareTripleTerm</th>
<th>Results</th>
</tr>
<tr>
<td><code>compareTripleTerm(&lt;&lt;(:s :p :o)&gt;&gt;, &lt;&lt;(:s :p :o)&gt;&gt;)</code></td>
<td>0</td>
</tr>
<tr>
<td><code>compareTripleTerm(&lt;&lt;(:s :p 123)&gt;&gt;, &lt;&lt;(:s :p 124)&gt;&gt;)</code></td>
<td>-1</td>
</tr>
<tr>
<td><code>compareTripleTerm(&lt;&lt;(:s :p 123)&gt;&gt;, &lt;&lt;(:s :p 122)&gt;&gt;)</code></td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
</section>

<section id="func-isIRI">
<span id="func-isURI"></span>
<h5>isIRI</h5>
Expand Down
Loading