Skip to content
114 changes: 102 additions & 12 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-compareTripleTerm">compareTripleTerm</a>(A, B), 0)
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
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a href="#func-compareTripleTerm">compareTripleTerm</a>(A, B), 0)
<a data-cite="XPATH-FUNCTIONS-31#func-numeric-equal">op:numeric-equal</a>(<a
href="#func-compareTripleTerm">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-compareTripleTerm">compareTripleTerm</a>(A, B), 0))
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
<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-compareTripleTerm">compareTripleTerm</a>(A, B), 0))
<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-compareTripleTerm">compareTripleTerm</a>(A, B), 0))

</td>
<td>xsd:boolean</td>
</tr>
Expand All @@ -5469,18 +5466,49 @@ <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-compareTripleTerm">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-compareTripleTerm">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-compareTripleTerm">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-compareTripleTerm">compareTripleTerm</a>(A, B), -1))
</td>
<td>xsd:boolean</td>
</tr>
</tbody>
</table>
<p>
<span id="ebv-arg"></span>xsd:boolean function arguments marked with "(EBV)" are
coerced to xsd:boolean by evaluating the <a href="#ebv">effective boolean value of that
argument.</a>
</p>
<p>
Operators <span class="SPARQLoperator">=</span> and <span class="SPARQLoperator">!=</span> applied to
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>
apply the operator to each of the components.
</p>
<section id="operatorExtensibility">
<h4>Operator Extensibility</h4>
<p>SPARQL language extensions may provide additional associations between operators and
Expand Down Expand Up @@ -6084,6 +6112,68 @@ <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 comparison operators,
such as "=" and "&lt;",
for the case of comparing <a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple Terms</a>.
The function is used 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><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2.
If <code><a href="#func-subject">SUBJECT</a>(term1) &lt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-subject">SUBJECT</a>(term1) &gt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3.
If <code><a href="#func-predicate">PREDICATE</a>(term1) &lt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-predicate">PREDICATE</a>(term1) &gt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0.
If <code><a href="#func-object">OBJECT</a>(term1) &lt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-object">OBJECT</a>(term1) &gt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
</ol>
Comment on lines +6134 to +6150
Copy link
Member

Choose a reason for hiding this comment

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

We make life easier for ourselves, by formatting the ReSpec/HTML source with line breaks and such. We should carry that through to readers, with formatting like the following:

Suggested change
<ol>
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2.
If <code><a href="#func-subject">SUBJECT</a>(term1) &lt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-subject">SUBJECT</a>(term1) &gt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3.
If <code><a href="#func-predicate">PREDICATE</a>(term1) &lt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-predicate">PREDICATE</a>(term1) &gt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0.
If <code><a href="#func-object">OBJECT</a>(term1) &lt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1.
If <code><a href="#func-object">OBJECT</a>(term1) &gt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1.
If any of the evaluations causes an error, raise an error.
</li>
</ol>
<ol>
<li>
<ol type="i">
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) = <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, go to step 2.</li>
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) &lt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return -1.</li>
<li>If <code><a href="#func-subject">SUBJECT</a>(term1) &gt; <a href="#func-subject">SUBJECT</a>(term2)</code> evaluates to true, return 1.</li>
<li>If any of the evaluations causes an error, raise an error.</li>
</ol>
</li>
<li>
<ol type="i">
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) = <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, go to step 3.</li>
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) &lt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return -1.</li>
<li>If <code><a href="#func-predicate">PREDICATE</a>(term1) &gt; <a href="#func-predicate">PREDICATE</a>(term2)</code> evaluates to true, return 1.</li>
<li>If any of the evaluations causes an error, raise an error.</li>
</ol>
</li>
<li>
<ol type="i">
<li>If <code><a href="#func-object">OBJECT</a>(term1) = <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 0.</li>
<li>If <code><a href="#func-object">OBJECT</a>(term1) &lt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return -1.</li>
<li>If <code><a href="#func-object">OBJECT</a>(term1) &gt; <a href="#func-object">OBJECT</a>(term2)</code> evaluates to true, return 1.</li>
<li>If any of the evaluations causes an error, raise an error.</li>
</ol>
</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