-
Notifications
You must be signed in to change notification settings - Fork 2
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
Open
rubensworks
wants to merge
8
commits into
main
Choose a base branch
from
feature/compare-triple-terms
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5603a21
Add missing value comparison operators for triple terms
rubensworks e9924bd
Support triple terms in ORDER BY
rubensworks 7213f87
Fix links to compareTripleTerm
rubensworks cba3ec1
Apply suggestions from code review
rubensworks 3f20202
Link to SUBJECT, PREDICATE, and OBJECT functions
rubensworks 189d62e
Remove obsolete sentence about triple terms in operator mapping table
rubensworks def10d9
Use term1/2 instead of A/B in func-compareTripleTerm
rubensworks bf53dac
Clarify next step in func-compareTripleTerm
rubensworks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||||||||||||||||
<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>) | ||||||||||||||||
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. Making source more readable. A little manual
Suggested change
|
||||||||||||||||
</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. | ||||||||||||||||
Comment on lines
+6128
to
+6129
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. Making source more readable. A little manual
Suggested change
|
||||||||||||||||
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> | ||||||||||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
.