Extensions of Operators
The tables provided below provide the definitions of the comparison and arithmetic operations that are implemented by Tentris.
The type numeric captures the XSD numeric types.
The results of arithmetic operations on numeric types are defined here,
Explicit Casts/Constructor Functions
Tentris supports using any recognized datatype as an explicit cast operator or type constructor.
For example, the expression xsd:int(?arg) produces an xsd:int value when provided with a string or typed literal.
If ?arg is bound to a string literal such as "1", the constructor creates a new xsd:int value.
If ?arg is bound to a typed literal like "1"^^xsd:short, the expression performs a cast to xsd:int.
If the cast/constructor fails to produce a valid literal of the given type, the function produces the error/null/UNDEF value.
Note that this example assumes the xsd prefix has been declared in the query.
This feature extends the SPARQL standard, which only includes a limited set of such casts and constructors, namely
xsd:boolean(?arg), xsd:string(?arg), xsd:integer(?arg), xsd:decimal(?arg), xsd:double(?arg), xsd:float(?arg), and xsd:dateTime(?arg).
For details on xsd datatype construction and casting, refer to XPath 3.1 Constructor functions and Casting respectively.
Comparison Operations
Operation (=, !=, >, >=, <, <=) | Type(A) | Type(B) | Result Type |
|---|---|---|---|
| A op B | numeric | numeric | xsd:boolean |
| A op B | owl:rational | owl:rational | xsd:boolean |
| A op B | owl:real | owl:real | xsd:boolean |
| A op B | xsd:string | xsd:anyURI | xsd:boolean |
| A op B | xsd:string | xsd:string | xsd:boolean |
| A op B | rdf:langString | rdf:langString | xsd:boolean |
| A op B | xsd:anyURI | xsd:anyURI | xsd:boolean |
| A op B | xsd:anyURI | xsd:string | xsd:boolean |
| A op B | xsd:boolean | xsd:boolean | xsd:boolean |
| A op B | xsd:date | xsd:date | xsd:boolean |
| A op B | xsd:date | xsd:dateTime | xsd:boolean |
| A op B | xsd:date | xsd:dateTimeStamp | xsd:boolean |
| A op B | xsd:date | xsd:gDay | xsd:boolean1 |
| A op B | xsd:date | xsd:gMonth | xsd:boolean1 |
| A op B | xsd:date | xsd:gMonthDay | xsd:boolean1 |
| A op B | xsd:date | xsd:gYear | xsd:boolean1 |
| A op B | xsd:date | xsd:gYearMonth | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:date | xsd:boolean |
| A op B | xsd:dateTime | xsd:dateTime | xsd:boolean |
| A op B | xsd:dateTime | xsd:dateTimeStamp | xsd:boolean |
| A op B | xsd:dateTime | xsd:gDay | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:gMonth | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:gMonthDay | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:gYear | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:gYearMonth | xsd:boolean1 |
| A op B | xsd:dateTime | xsd:time | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:date | xsd:boolean |
| A op B | xsd:dateTimeStamp | xsd:dateTime | xsd:boolean |
| A op B | xsd:dateTimeStamp | xsd:dateTimeStamp | xsd:boolean |
| A op B | xsd:dateTimeStamp | xsd:gDay | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:gMonth | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:gMonthDay | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:gYear | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:gYearMonth | xsd:boolean1 |
| A op B | xsd:dateTimeStamp | xsd:time | xsd:boolean1 |
| A op B | xsd:dayTimeDuration | xsd:dayTimeDuration | xsd:boolean |
| A op B | xsd:dayTimeDuration | xsd:duration | xsd:boolean |
| A op B | xsd:dayTimeDuration | xsd:yearMonthDuration | xsd:boolean |
| A op B | xsd:duration | xsd:dayTimeDuration | xsd:boolean |
| A op B | xsd:duration | xsd:duration | xsd:boolean |
| A op B | xsd:duration | xsd:yearMonthDuration | xsd:boolean |
| A op B | xsd:gDay | xsd:date | xsd:boolean1 |
| A op B | xsd:gDay | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:gDay | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:gDay | xsd:gDay | xsd:boolean |
| A op B | xsd:gMonth | xsd:date | xsd:boolean1 |
| A op B | xsd:gMonth | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:gMonth | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:gMonth | xsd:gMonth | xsd:boolean |
| A op B | xsd:gMonthDay | xsd:date | xsd:boolean1 |
| A op B | xsd:gMonthDay | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:gMonthDay | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:gMonthDay | xsd:gMonthDay | xsd:boolean |
| A op B | xsd:gYear | xsd:date | xsd:boolean1 |
| A op B | xsd:gYear | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:gYear | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:gYear | xsd:gYear | xsd:boolean |
| A op B | xsd:gYearMonth | xsd:date | xsd:boolean1 |
| A op B | xsd:gYearMonth | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:gYearMonth | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:gYearMonth | xsd:gYearMonth | xsd:boolean |
| A op B | xsd:time | xsd:dateTime | xsd:boolean1 |
| A op B | xsd:time | xsd:dateTimeStamp | xsd:boolean1 |
| A op B | xsd:time | xsd:time | xsd:boolean |
| A op B | xsd:yearMonthDuration | xsd:dayTimeDuration | xsd:boolean |
| A op B | xsd:yearMonthDuration | xsd:duration | xsd:boolean |
| A op B | xsd:yearMonthDuration | xsd:yearMonthDuration | xsd:boolean |
| A op B | xsd:hexBinary | xsd:hexBinary | xsd:boolean |
| A op B | xsd:base64Binary | xsd:base64Binary | xsd:boolean |
Arithmetic Operations
For date and time types, Tentris uses and extends the definitions of XPath.
Addition
| Operation | Type(A) | Type(B) | Result Type |
|---|---|---|---|
| A + B | numeric | numeric | numeric |
| A + B | xsd:date | xsd:dayTimeDuration | xsd:date |
| A + B | xsd:date | xsd:duration | xsd:date |
| A + B | xsd:date | xsd:yearMonthDuration | xsd:date |
| A + B | xsd:dateTime | xsd:dayTimeDuration | xsd:dateTime |
| A + B | xsd:dateTime | xsd:duration | xsd:dateTime |
| A + B | xsd:dateTime | xsd:yearMonthDuration | xsd:dateTime |
| A + B | xsd:dateTimeStamp | xsd:dayTimeDuration | xsd:dateTimeStamp |
| A + B | xsd:dateTimeStamp | xsd:duration | xsd:dateTimeStamp |
| A + B | xsd:dateTimeStamp | xsd:yearMonthDuration | xsd:dateTimeStamp |
| A + B | xsd:dayTimeDuration | xsd:dayTimeDuration | xsd:dayTimeDuration |
| A + B | xsd:dayTimeDuration | xsd:duration | xsd:duration |
| A + B | xsd:dayTimeDuration | xsd:yearMonthDuration | xsd:duration |
| A + B | xsd:duration | xsd:dayTimeDuration | xsd:duration |
| A + B | xsd:duration | xsd:duration | xsd:duration |
| A + B | xsd:duration | xsd:yearMonthDuration | xsd:duration |
| A + B | xsd:time | xsd:dayTimeDuration | xsd:time |
| A + B | xsd:yearMonthDuration | xsd:dayTimeDuration | xsd:duration |
| A + B | xsd:yearMonthDuration | xsd:duration | xsd:duration |
| A + B | xsd:yearMonthDuration | xsd:yearMonthDuration | xsd:yearMonthDuration |
Subtraction
| Operation | Type(A) | Type(B) | Result Type |
|---|---|---|---|
| A - B | numeric | numeric | numeric |
| A - B | xsd:date | xsd:date | xsd:dayTimeDuration |
| A - B | xsd:date | xsd:dateTime | xsd:dayTimeDuration |
| A - B | xsd:date | xsd:dateTimeStamp | xsd:dayTimeDuration |
| A - B | xsd:date | xsd:dayTimeDuration | xsd:date |
| A - B | xsd:date | xsd:duration | xsd:date |
| A - B | xsd:date | xsd:yearMonthDuration | xsd:date |
| A - B | xsd:dateTime | xsd:date | xsd:dayTimeDuration |
| A - B | xsd:dateTime | xsd:dateTime | xsd:dayTimeDuration |
| A - B | xsd:dateTime | xsd:dateTimeStamp | xsd:dayTimeDuration |
| A - B | xsd:dateTime | xsd:dayTimeDuration | xsd:dateTime |
| A - B | xsd:dateTime | xsd:duration | xsd:dateTime |
| A - B | xsd:dateTime | xsd:time | xsd:dayTimeDuration |
| A - B | xsd:dateTime | xsd:yearMonthDuration | xsd:dateTime |
| A - B | xsd:dateTimeStamp | xsd:date | xsd:dayTimeDuration |
| A - B | xsd:dateTimeStamp | xsd:dateTime | xsd:dayTimeDuration |
| A - B | xsd:dateTimeStamp | xsd:dateTimeStamp | xsd:dayTimeDuration |
| A - B | xsd:dateTimeStamp | xsd:dayTimeDuration | xsd:dateTimeStamp |
| A - B | xsd:dateTimeStamp | xsd:duration | xsd:dateTimeStamp |
| A - B | xsd:dateTimeStamp | xsd:time | xsd:dayTimeDuration |
| A - B | xsd:dateTimeStamp | xsd:yearMonthDuration | xsd:dateTimeStamp |
| A - B | xsd:dayTimeDuration | xsd:dayTimeDuration | xsd:dayTimeDuration |
| A - B | xsd:dayTimeDuration | xsd:duration | xsd:duration |
| A - B | xsd:duration | xsd:dayTimeDuration | xsd:duration |
| A - B | xsd:duration | xsd:duration | xsd:duration |
| A - B | xsd:duration | xsd:yearMonthDuration | xsd:duration |
| A - B | xsd:time | xsd:dateTime | xsd:dayTimeDuration |
| A - B | xsd:time | xsd:dateTimeStamp | xsd:dayTimeDuration |
| A - B | xsd:time | xsd:dayTimeDuration | xsd:time |
| A - B | xsd:time | xsd:time | xsd:dayTimeDuration |
| A - B | xsd:yearMonthDuration | xsd:duration | xsd:duration |
| A - B | xsd:yearMonthDuration | xsd:yearMonthDuration | xsd:yearMonthDuration |
Multiplication
| Operation | Type(A) | Type(B) | Result Type |
|---|---|---|---|
| A * B | numeric | numeric | numeric |
| A * B | xsd:dayTimeDuration | numeric | xsd:dayTimeDuration |
| A * B | xsd:duration | numeric | xsd:duration |
| A * B | xsd:yearMonthDuration | numeric | xsd:yearMonthDuration |
Division
| Operation | Type(A) | Type(B) | Result Type |
|---|---|---|---|
| A/B | numeric | numeric | numeric |
| A/B | xsd:dayTimeDuration | numeric | xsd:dayTimeDuration |
| A/B | xsd:dayTimeDuration | xsd:dayTimeDuration | xsd:decimal |
| A/B | xsd:yearMonthDuration | numeric | xsd:yearMonthDuration |
| A/B | xsd:yearMonthDuration | xsd:yearMonthDuration | xsd:decimal |