Built-Ins
8. Built-Ins
The built-ins for OO jDREW are based on the SWRL builtins. Although the goal is
to implement the complete set of SWRL built-ins, not all a currently implemented. Unimplemented built-ins are currently marked with [ unimplemented ].
Date and Time types are currently not implemented, therefore any details dealing with dates and times are not currently implemented.
Any differences from the SWRL built-ins are also noted in the this document.
While Swrl built-ins are identified using the
http://www.w3.org/2003/11/swrlb
namespace, no name space is used when using these builtins in OO jDREW. Additionally, the builtin type Integer is used in place of xsd:int.
8.1. Built-Ins for Comparisons
- equal
(from XQuery op:numeric-equal,
op:compare,
op:boolean-equal)
Satisfied iff the first argument and the second argument are the same.
- notEqual
(from equal)
The negation of equal. Satisfied iff the first argument and the second argument are not the same.
- lessThan
(from XQuery op:numeric-less-than,
op:compare)
Satisfied iff the first argument and the second argument are both in some implemented (In this case, Real, Integer and String are supported)
type and the first argument is less than the second argument according to
a type-specific ordering (partial or total), if there is one defined for the
type.
[ difference ]The ordering function for untyped literals is not defined, and therefore not comparable.
- lessThanOrEqual
(from lessThan, equal)
Either less than, as above, or equal, as above.
- greaterThan
(from XQuery op:numeric-greater-than,
op:compare)
Similarly to lessThan.
- greaterThanOrEqual
(from greaterThan, equal)
Similarly to lessThanOrEqual.
8.2. Math Built-Ins
The following built-ins are defined for various numeric types (Integer and Real currently).
For the relation to be satisfied the arguments all have to belong to some
numeric type for which the relation is defined.
- add
(from XQuery op:numeric-add)
Satisfied iff the first argument is equal to the arithmetic sum of the second argument through the last argument.
If the first argument is a variable then it will be bound to the result of the artihmetic sum of the second through last arguments.
- subtract
(from XQuery op:numeric-subtract)
Satisfied iff the first argument is equal to the arithmetic difference of the second argument minus the third argument.
If the first argument is a variable then it will be bound to the arithmetic difference of the second argument minus the third argument.
- multiply
(from XQuery op:numeric-multiply)
Satisfied iff the first argument is equal to the arithmetic product of the second argument through the last argument.
If the first argument is a variable then it will be bound to the arithmetic product of the second argument through the last argument.
- divide
(from XQuery op:numeric-divide)
Satisfied iff the first argument is equal to the arithmetic quotient of the second argument divided by the third argument.
If the first argument is a variable then it will be bound to the arithmetic quotient of the second argument divided by the third argument.
- integerDivide
(from XQuery op:numeric-integer-divide)
Satisfied if the first argument is the arithmetic quotient of the second argument idiv the third argument. If the numerator is not evenly divided by the divisor, then the quotient is the Integereger value obtained, ignoring any remainder that results from the division (that is, no rounding is performed).
If the first argument is a variable then it will be bound to the arithmetic quotient of the second argument idiv the third argument.
- mod
(from XQuery op:numeric-mod)
Satisfied if the first argument represents the remainder resulting from dividing the second argument, the dividend, by the third argument, the divisor. The operation a mod b for operands that are Integereger or xsd:decimal, or types derived from them, produces a result such that (a idiv b)*b+(a mod b) is equal to a and the magnitude of the result is always less than the magnitude of b. This identity holds even in the special case that the dividend is the negative integer of largest possible magnitude for its type and the divisor is -1 (the remainder is 0). It follows from this rule that the sign of the result is the sign of the dividend
- pow
Satisfied iff the first argument is equal to the result of the second argument raised to the third argument power.
If the first argument is a variable then it will be bound to the result of the second argument raised to the third argument power.
- [ unimplemented ]unaryPlus
(from XQuery op:numeric-unary-plus)
Satisfied iff the first argument is equal to the second argument with its sign unchanged.
- [ unimplemented ]unaryMinus
(from XQuery op:numeric-unary-minus)
Satisfied iff the first argument is equal to the second argument with its sign reversed.
- abs
(from XQuery fn:abs)
Satisfied iff the first argument is the absolute value of the second argument.
If the first argument is a variable then it will be bound to the absolute value of the second argument.
- ceiling
(from XQuery fn:ceiling)
Satisfied iff the first argument is the smallest number with no fractional part that is greater than or equal to the second argument.
If the first argument is a variable then it will be bound to the smallest number with no fractional part that is greater than or equal to the second argument.
- floor
(from XQuery fn:floor)
Satisfied iff the first argument is the largest number with no fractional part that is less than or equal to the second argument.
If the first argument is a variable then it will be bound to the largest number with no fractional part that is less than or equal to the second argument.
- round
(from XQuery fn:round)
Satisfied iff the first argument is equal to the nearest number to the second argument with no fractional part.
If the first argument is a variable then it will be bound to the nearest number to the second argument with no fractional part.
- [ unimplemented ]roundHalfToEven
(from XQuery fn:round-half-to-even)
Satisfied iff the first argument is equal to the second argument rounded to the given precision. If the fractional part is exactly half, the result is the number whose least significant digit is even.
- sin
Satisfied iff the first argument is equal to the sine of the radian value the second argument.
- cos
Satisfied iff the first argument is equal to the cosine of the radian value the second argument.
- tan
Satisfied iff the first argument is equal to the tangent of the radian value the second argument.
8.3. Built-Ins for Boolean Values
- [ unimplemented ]booleanNot
(from XQuery fn:not)
Satisfied iff the first argument is true and the second argument is false, or vice versa.
8.4. Built-Ins for Strings
The following built-ins are defined for strings (only), i.e., not untyped
literals with language tags.
- stringEqualIgnoreCase
Satisfied iff the first argument is the same as the second argument (upper/lower case ignored)
- stringConcat
(from XQuery fn:concat)
Satisfied iff the first argument is equal to the string resulting from the concatenation of the strings the second argument through the last argument.
If the first argument is a variable then it will be bound to the concatenation of the strings the second argument through the last argument.
- substring
(from XQuery fn:substring)
Satisfied iff the first argument is equal to the substring of optional length the fourth argument starting at character offset the third argument in the string the second argument.
If the first argument is a variable then it will be bound to the substring of optional length the fourth argument starting at character offset the third argument in the string the second argument.
- stringLength
(from XQuery fn:string-length)
Satisfied iff the first argument is equal to the length of the second argument.
If the first argument is a variable then it will be bound to the length of the second argument.
- [ unimplemented ]normalizeSpace
(from XQuery fn:normalize-space)
Satisfied iff the first argument is equal to the whitespace-normalized value of the second argument.
- upperCase
(from XQuery fn:upper-case)
Satisfied iff the first argument is equal to the upper-cased value of the second argument.
If the first argument is a variable then it will be bound to the upper-cased value of the second argument.
- lowerCase
(from XQuery fn:lower-case)
Satisfied iff the first argument is equal to the lower-cased value of the second argument.
If the first argument is a variable then it will be bound to the lower-cased value of the second argument.
- [ unimplemented ]translate
(from XQuery fn:translate)
Satisfied iff the first argument is equal to the second argument with occurrences of characters contained in the third argument replaced by the character at the corresponding position in the string the fourth argument.
- contains
(from XQuery fn:contains)
Satisfied iff the first argument contains the second argument (case sensitive).
- containsIgnoreCase
Satisfied iff the first argument contains the second argument (case ignored).
- startsWith
(from XQuery fn:starts-with)
Satisfied iff the first argument starts with the second argument.
- endsWith
(from XQuery fn:ends-with)
Satisfied iff the first argument ends with the second argument.
- [ unimplemented ]substringBefore
(from XQuery fn:substring-before)
Satisfied iff the first argument is the characters of the second argument that precede the characters of the third argument.
- [ unimplemented ]substringAfter
(from XQuery fn:substring-after)
Satisfied iff the first argument is the characters of the second argument that follow the characters of the third argument.
- [ unimplemented ]matches
(from XQuery fn:matches)
Satisfied iff the first argument matches the regular expression the second argument.
- [ unimplemented ]replace
(from XQuery fn:replace)
Satisfied iff the first argument is equal to the value of the second argument with every substring matched by the regular expression the third argument replaced by the replacement string the fourth argument.
- [ unimplemented ]tokenize
(from XQuery fn:tokenize)
Satisfied iff the first argument is a sequence of one or more strings whose values are substrings of the second argument separated by substrings that match the regular expression the third argument.
[ unimplemented ]8.5. Built-Ins for Date, Time and Duration
The following built-ins are defined for the XML Schema date, time, and
duration datatypes, only, as appropriate.
- yearMonthDuration
(from XQuery xdt:yearMonthDuration)
Satisfied iff the first argument is the xsd:duration representation consisting
of the year the second argument and month the third argument.
- dayTimeDuration
(from XQuery xdt:dayTimeDuration)
Satisfied iff the first argument is the xsd:duration representation consisting
of the days the second argument, hours the third argument, minutes the fourth argument, and seconds the fifth argument.
- dateTime
Satisfied iff the first argument is the xsd:dateTime representation consisting
of the year the second argument, month the third argument, day the fourth argument, hours the fifth argument, minutes the sixth argument, seconds the seventh argument, and timezone the eighth argument.
- date
Satisfied iff the first argument is the xsd:date representation consisting
of the year the second argument, month the third argument, day the fourth argument, and timezone the fifth argument.
- time
Satisfied iff the first argument is the xsd:time representation consisting
of the hours the second argument, minutes the third argument, seconds the fourth argument, and timezone the fifth argument.
- addYearMonthDurations
(from XQuery op:add-yearMonthDurations)
Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic sum of the yearMonthDuration the second argument through the yearMonthDuration the last argument.
- subtractYearMonthDurations
(from XQuery op:subtract-yearMonthDurations)
Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic difference of the yearMonthDuration the second argument minus the yearMonthDuration the third argument.
- multiplyYearMonthDuration
(from XQuery op:multiply-yearMonthDuration)
Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic product of the yearMonthDuration the second argument multiplied by the third argument.
- divideYearMonthDurations
(from XQuery op:divide-yearMonthDuration)
Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic remainder of the yearMonthDuration the second argument divided by the third argument.
- addDayTimeDurations
(from XQuery op:add-dayTimeDurations)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic sum of the dayTimeDuration the second argument through the dayTimeDuration the last argument.
- subtractDayTimeDurations
(from XQuery op:subtract-dayTimeDurations)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the dayTimeDuration the second argument minus the dayTimeDuration the third argument.
- multiplyDayTimeDurations
(from XQuery op:multiply-dayTimeDuration)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic product of the dayTimeDuration the second argument multiplied by the third argument.
- divideDayTimeDuration
(from XQuery op:divide-dayTimeDuration)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic remainder of the dayTimeDuration the second argument divided by the third argument.
- subtractDates
(from XQuery op:subtract-dates)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the xsd:date the third argument.
- subtractTimes
(from XQuery op:subtract-times)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:time the second argument minus the xsd:time the third argument.
- addYearMonthDurationToDateTime
(from XQuery op:add-yearMonthDuration-to-dateTime)
Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic sum of the xsd:dateTime the second argument plus the yearMonthDuration the third argument.
- addDayTimeDurationToDateTime
(from XQuery op:add-dayTimeDuration-to-dateTime)
Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic sum of the xsd:dateTime the second argument plus the dayTimeDuration the third argument.
- subtractYearMonthDurationFromDateTime
(from XQuery op:subtract-yearMonthDuration-from-dateTime)
Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the yearMonthDuration the third argument.
- subtractDayTimeDurationFromDateTime
(from XQuery op:subtract-dayTimeDuration-from-dateTime)
Satisfied iff the xsd:dateTime the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the dayTimeDuration the third argument.
- addYearMonthDurationToDate
(from XQuery op:add-yearMonthDuration-to-date)
Satisfied iff the xsd:date the first argument is equal to the arithmetic sum of the xsd:date the second argument plus the yearMonthDuration the third argument.
- addDayTimeDurationToDate
(from XQuery op:add-dayTimeDuration-to-date)
Satisfied iff the xsd:date the first argument is equal to the arithmetic sum of the xsd:date the second argument plus the dayTimeDuration the third argument.
- subtractYearMonthDurationFromDate
(from XQuery op:subtract-yearMonthDuration-from-date)
Satisfied iff the xsd:date the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the yearMonthDuration the third argument.
- subtractDayTimeDurationFromDate
(from XQuery op:subtract-dayTimeDuration-from-date)
Satisfied iff the xsd:date the first argument is equal to the arithmetic difference of the xsd:date the second argument minus the yearMonthDuration the third argument.
- addDayTimeDurationToTime
(from XQuery op:add-dayTimeDuration-to-time)
Satisfied iff the xsd:time the first argument is equal to the arithmetic sum of the xsd:time the second argument plus the dayTimeDuration the third argument.
- subtractDayTimeDurationFromTime
(from XQuery op:subtract-dayTimeDuration-from-time)
Satisfied iff the xsd:time the first argument is equal to the arithmetic difference of the xsd:time the second argument minus the dayTimeDuration the third argument.
- subtractDateTimesYieldingYearMonthDuration
(from XQuery fn:subtract-dateTimes-yielding-yearMonthDuration)
Satisfied iff the yearMonthDuration the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the xsd:dateTime the third argument.
- subtractDateTimesYieldingDayTimeDuration
(from XQuery fn:subtract-dateTimes-yielding-dayTimeDuration)
Satisfied iff the dayTimeDuration the first argument is equal to the arithmetic difference of the xsd:dateTime the second argument minus the xsd:dateTime the third argument.
[ unimplemented ]8.6. Built-Ins for URIs
The following built-ins are defined for the XML Schema datatypes related to
URIs.
- resolveURI
(from XQuery op:resolve-uri)
Satisfied iff the URI reference the first argument is equal to the value of the URI reference the second argument resolved relative to the base URI the third argument.
- anyURI
Satisfied iff the first argument is a URI reference consisting of the
scheme the second argument,
host the third argument,
port the fourth argument,
path the fifth argument,
query the sixth argument, and
fragment the seventh argument.
[ unimplemented ]8.7. Built-Ins for Lists
The following built-ins are defined for RDF-style lists.
(Note that these built-ins are not usable in OWL DL or OWL Lite as
RDF-style lists can only be used as OWL data in OWL Full.)
- listConcat
(from Common Lisp append)
Satisfied iff the first argument is a list representing the concatenation of the lists the second argument through the last argument.
- listIntersection
Satisfied iff the first argument is a list containing elements found in both the list the second argument and the list the third argument.
- listSubtraction
Satisfied iff the first argument is a list containing the elements of the list the second argument that are not members of the list the third argument.
- member
Satisfied iff the first argument is a member of the list the second argument.
- length
(from Common Lisp list-length)
Satisfied iff the first argument is the length of the list the second argument (number of members of the list).
- first
(from rdf:first)
Satisfied iff the first argument is the first member of the list the second argument.
- rest
(from rdf:rest)
Satisfied iff the first argument is a list containing all members of the list the second argument except the first member (the head).
- sublist
Satisfied iff the list the first argument contains the list the second argument.
- empty
(from rdf:nil)
Satisfied iff the list the first argument is an empty list.