-
Notifications
You must be signed in to change notification settings - Fork 3
Add missing comparison operators for triple terms #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5603a21
e9924bd
7213f87
cba3ec1
3f20202
189d62e
def10d9
bf53dac
341047f
48d4d85
5ef760d
900a4c8
e4b1cb4
ef9fac4
5ab6c98
70ea234
e5bfd34
5d9c49f
bdb6d5d
2ccda34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3674,7 +3674,7 @@ <h3>ORDER BY</h3> | |
| <p>The <a href="#op_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 | ||
| IRIs are ordered by comparing them as literals with datatype <code>xsd:string</code>.</p> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to say something about case-sensitive ordering being the norm in some environments, and case-insensitive ordering in others, as well as how to override both norms, assuming that is possible anywhere if not everywhere. I know we've said in some place(s) that lexical ordering is to be code point order, which is effectively case-sensitive, but I don't think this will suffice for all use cases. So far as I knowI believe code point order will also prove problematic when trying to compare, for instance,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Function and operators" has (I don't see anything new to SPARQL 1.2 here so I think it's not for this PR.) |
||
| <p>SPARQL also fixes an order between some kinds of RDF terms that would not otherwise be | ||
| ordered:</p> | ||
|
|
@@ -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> | ||
|
|
@@ -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">&&</a><br/> | ||
| ( A.predicate = B.predicate ) <a href="#logical-and-operator" class="SPARQLoperator">&&</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) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
|
|
@@ -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)) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
|
|
@@ -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"><</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) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
| <tr> | ||
| <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken"><=</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)) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
| <tr> | ||
| <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">></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) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
| <tr> | ||
| <th><a href="#rRelationalExpression" title="RelationalExpression">A <span class="FAOTtoken">>=</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)) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </td> | ||
| <td>xsd:boolean</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| <p> | ||
|
|
@@ -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>) | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </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 "<" operator | ||
| in Section <a href="#OperatorMapping" class="sectionRef"></a>. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </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. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 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. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| If <code>SUBJECT(A) < SUBJECT(B)</code> evaluates to true, return -1. | ||
| If <code>SUBJECT(A) > SUBJECT(B)</code> evaluates to true, return 1. | ||
| If any of the evalutions cause an error, raise an error. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </li> | ||
| <li>If <code>PREDICATE(A) = PREDICATE(B)</code> evaluates to true, go to the next step. | ||
| If <code>PREDICATE(A) < PREDICATE(B)</code> evaluates to true, return -1. | ||
| If <code>PREDICATE(A) > PREDICATE(B)</code> evaluates to true, return 1. | ||
| If any of the evalutions cause an error, raise an error. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </li> | ||
| <li>If <code>OBJECT(A) = OBJECT(B)</code> evaluates to true, return 0. | ||
| If <code>OBJECT(A) < OBJECT(B)</code> evaluates to true, return -1. | ||
| If <code>OBJECT(A) > OBJECT(B)</code> evaluates to true, return 1. | ||
| If any of the evalutions cause an error, raise an error. | ||
rubensworks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </li> | ||
| </ol> | ||
|
|
||
| <p>Examples:</p> | ||
| <div class="result"> | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <th>compareTripleTerm</th> | ||
| <th>Results</th> | ||
| </tr> | ||
| <tr> | ||
| <td><code>compareTripleTerm(<<(:s :p :o)>>, <<(:s :p :o)>>)</code></td> | ||
| <td>0</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>compareTripleTerm(<<(:s :p 123)>>, <<(:s :p 124)>>)</code></td> | ||
| <td>-1</td> | ||
| </tr> | ||
| <tr> | ||
| <td><code>compareTripleTerm(<<(:s :p 123)>>, <<(:s :p 122)>>)</code></td> | ||
| <td>1</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
| </section> | ||
|
|
||
| <section id="func-isIRI"> | ||
| <span id="func-isURI"></span> | ||
| <h5>isIRI</h5> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.