W3C | Semantic Web | SWAP
It is valuable that the functions and oprators in XML and RDF query langauges be aligned and interconvertable, if not simply identical.
The convention used in Cwm is for a function to be considered a functional Property relating (as subject) the argument, if single, or rdf:List of arguments, if multiple, to (as object) the returned value. (See Tutorial on Builtins).
There is a generic style diufference in that RDF Properties use camel case, and I don't like the use of a hyphen in a name, when one might expect to be able to use it as an operator. RDF/XML does allow a hyphen, as does N3 in full form (and has at times allowed it in the qname form)
This is a (working) copy of the table of contents of the XQ/XPath Functions and Operators.
These are XML-sepcific. I would not expect them to be picked up in RDF query langauge.
2.1 fn:node-kind
2.2 fn:node-name
2.3 fn:string
2.4 fn:data
2.5 fn:base-uri
2.6 fn:unique-ID
This is useful. I was thinking of more levels of progress, warning, error. This is less of an essential for interop.
3.1 Examples
4.1 Constructor
Functions for XML Schema Built-in Types
4.2 Constructor
Functions for User-Defined Types
5 Functions and Operators on
Numerics
5.1 Numeric Types
These should dirtectly map into builtins. These already (2003/03) exist in cwm with different names in math: namespace.
They take the form in RDF of a property of the List of arguments, as in
the N3 (2 3) math:sum 5.
When used as back-up of operators, the argument list will tend to be of length 2, though sum and product take a list of any lenth. (Note: Zero length should of course yield for consistency the idenity under the operation: 0 for sum and 1 for product)
Note the naming style difference, that RDF Properties are by convention names using role nouns, such as "parent" rather than the verbal form "isParentOf".
5.2.1 op:numeric-add -- math:sum
5.2.2 op:numeric-subtract -- math:difference
5.2.3 op:numeric-multiply -- math:product
5.2.4 op:numeric-divide -- math:quotient
5.2.5 op:numeric-integer-divide
-- math:integerQuotient
5.2.6 op:numeric-mod --
math:remainder
5.2.7 op:numeric-unary-plus ---- This is the identity operation (aka NOP). math:isEqualTo works.
5.2.8 op:numeric-unary-minus -- math:negation
The math: vocabulary has these and also their nergatibes
??? -- notEqualTo
??? -- notLessThan
??? -- notGreaterThan
5.3.1 op:numeric-equal -- math:equalTo
5.3.2 op:numeric-less-than --math:lessThan
5.3.3 op:numeric-greater-than -- math:greaterThan
The exact definitions of these functions may vary from the ones cwm uses. Cwm just uses python's built-in round on doubles.
@@There are open issues about the return type. Currently the spec says double is returned, which seems to me to be crazy when the whole point of the function is to get an int. It could be a size problem - python probably just uses variable length ints when necessary.
These XQ functions round up given k + 0.5 , some people prefer to round to the nearest even integer to prevent consistent bias upward to the average.
5.4.1 fn:floor
5.4.2 fn:ceiling
5.4.3 fn:round --
math:rounded
6 Functions on Strings --
These should dirtectly map into builtins
6.1 String Types
6.2 Functions to Assemble and
Disassemble Strings
6.2.1 fn:codepoints-to-string
6.2.2 fn:string-to-codepoints
6.3 Equality and Comparison of
Strings
6.3.1 fn:compare
6.4 Functions on String Values
6.4.1 fn:concat
6.4.2 fn:string-join
6.4.3 fn:starts-with
6.4.4 fn:ends-with
6.4.5 fn:contains
6.4.6 fn:substring
6.4.7 fn:string-length
6.4.8 fn:substring-before
6.4.9 fn:substring-after
6.4.10 fn:normalize-space
6.4.11 fn:normalize-unicode
6.4.12 fn:upper-case
6.4.13 fn:lower-case
6.4.14 fn:translate
6.4.15 fn:string-pad
6.4.16 fn:matches
6.4.17 fn:replace
6.4.18 fn:tokenize
6.4.19 fn:escape-uri
7 Functions and Operators on
Booleans
7.1 Boolean Constructor
Functions
7.1.1 fn:true
7.1.2 fn:false
7.2 Operators on Boolean
Values
7.2.1 op:boolean-equal
7.2.2 op:boolean-less-than
7.2.3 op:boolean-greater-than
7.3 Functions on Boolean
Values
7.3.1 fn:not
8 Functions and
Operators on Durations, Dates, and Times
8.1 Duration, Date, and Time
Types
8.2 Two Totally Ordered
Subtypes of Duration
8.2.1 yearMonthDuration
8.2.2 dayTimeDuration
8.3 Comparisons of
Duration, Date and Time Values
8.3.1 op:duration-equal
8.3.2 op:yearMonthDuration-equal
8.3.3 op:yearMonthDuration-less-than
8.3.4 op:yearMonthDuration-greater-than
8.3.5 op:dayTimeDuration-equal
8.3.6 op:dayTimeDuration-less-than
8.3.7 op:dayTimeDuration-greater-than
8.3.8 op:dateTime-equal
8.3.9 op:dateTime-less-than
8.3.10 op:dateTime-greater-than
8.3.11 op:date-equal
8.3.12 op:date-less-than
8.3.13 op:date-greater-than
8.3.14 op:time-equal
8.3.15 op:time-less-than
8.3.16 op:time-greater-than
8.3.17 op:gYearMonth-equal
8.3.18 op:gYear-equal
8.3.19 op:gMonthDay-equal
8.3.20 op:gMonth-equal
8.3.21 op:gDay-equal
8.4 Component Extraction Functions
on Duration, Date and Time Values
8.4.1 fn:get-years-from-yearMonthDuration
8.4.2 fn:get-months-from-yearMonthDuration
8.4.3 fn:get-days-from-dayTimeDuration
8.4.4 fn:get-hours-from-dayTimeDuration
8.4.5 fn:get-minutes-from-dayTimeDuration
8.4.6 fn:get-seconds-from-dayTimeDuration
8.4.7 fn:get-year-from-dateTime
8.4.8 fn:get-month-from-dateTime
8.4.9 fn:get-day-from-dateTime
8.4.10 fn:get-hours-from-dateTime
8.4.11 fn:get-minutes-from-dateTime
8.4.12 fn:get-seconds-from-dateTime
8.4.13 fn:get-timezone-from-dateTime
8.4.14 fn:get-year-from-date
8.4.15 fn:get-month-from-date
8.4.16 fn:get-day-from-date
8.4.17 fn:get-timezone-from-date
8.4.18 fn:get-hours-from-time
8.4.19 fn:get-minutes-from-time
8.4.20 fn:get-seconds-from-time
8.4.21 fn:get-timezone-from-time
8.5 Arithmetic Functions on
yearMonthDuration and dayTimeDuration
8.5.1 op:add-yearMonthDurations
8.5.2 op:subtract-yearMonthDurations
8.5.3 op:multiply-yearMonthDuration
8.5.4 op:divide-yearMonthDuration
8.5.5 op:add-dayTimeDurations
8.5.6 op:subtract-dayTimeDurations
8.5.7 op:multiply-dayTimeDuration
8.5.8 op:divide-dayTimeDuration
8.6 Timezone Functions
on dateTime, date, and time
8.6.1 fn:add-timezone-to-dateTime
8.6.2 fn:remove-timezone-from-dateTime
8.6.3 fn:add-timezone-to-date
8.6.4 fn:add-timezone-to-time
8.6.5 fn:remove-timezone-from-time
8.7 Adding and
Subtracting Durations From dateTime, date and time
8.7.1 fn:subtract-dateTimes-yielding-yearMonthDuration
8.7.2 fn:subtract-dateTimes-yielding-dayTimeDuration
8.7.3 op:subtract-dates
8.7.4 op:subtract-times
8.7.5 op:add-yearMonthDuration-to-dateTime
8.7.6 op:add-dayTimeDuration-to-dateTime
8.7.7 op:subtract-yearMonthDuration-from-dateTime
8.7.8 op:subtract-dayTimeDuration-from-dateTime
8.7.9 op:add-yearMonthDuration-to-date
8.7.10 op:add-dayTimeDuration-to-date
8.7.11 op:subtract-yearMonthDuration-from-date
8.7.12 op:subtract-dayTimeDuration-from-date
8.7.13 op:add-dayTimeDuration-to-time
8.7.14 op:subtract-dayTimeDuration-from-time
9 Functions Related to
QNames
9.1 Constructor Functions for
QNames
9.1.1 fn:QName-in-context
9.2 Functions Related to
QNames
9.2.1 op:QName-equal
9.2.2 fn:get-local-name-from-QName
9.2.3 fn:get-namespace-from-QName
9.2.4 fn:get-namespace-uri-for-prefix
9.2.5 fn:get-in-scope-namespaces
10 Functions and Operators for
anyURI
10.1 Constructor Functions for
anyURI
10.1.1 fn:resolve-uri
10.2 Functions on anyURI
10.2.1 op:anyURI-equal
11 Functions and Operators on
base64Binary and hexBinary
11.1 Comparisons of base64Binary and
hexBinary Values
11.1.1 op:hexBinary-equal
11.1.2 op:base64Binary-equal
12 Functions and Operators on
NOTATION
12.1 Functions on NOTATION
12.1.1 op:NOTATION-equal
13 Functions and Operators on
Nodes
13.1 Functions and Operators on
Nodes
13.1.1 fn:name
13.1.2 fn:local-name
13.1.3 fn:namespace-uri
13.1.4 fn:number
13.1.5 fn:lang
13.1.6 op:node-equal
13.1.7 fn:deep-equal
13.1.8 op:node-before
13.1.9 op:node-after
13.1.10 fn:root
14 Functions and Operators on
Sequences
14.1 Constructor Functions on
Sequences
14.1.1 op:to
14.2 Functions and Operators on
Sequences
14.2.1 fn:boolean
14.2.2 op:concatenate
14.2.3 fn:item-at
14.2.4 fn:index-of
14.2.5 fn:empty
14.2.6 fn:exists
14.2.7 fn:distinct-nodes
14.2.8 fn:distinct-values
14.2.9 fn:insert
14.2.10 fn:remove
14.2.11 fn:subsequence
14.2.12 fn:unordered
14.3 Equals, Union, Intersection and
Except
14.3.1 fn:sequence-deep-equal
14.3.2 fn:sequence-node-equal
14.3.3 op:union
14.3.4 op:intersect
14.3.5 op:except
14.4 Aggregate Functions
14.4.1 fn:count
14.4.2 fn:avg
14.4.3 fn:max
14.4.4 fn:min
14.4.5 fn:sum
14.5 Functions
that Generate Sequences
14.5.1 fn:id
14.5.2 fn:idref
14.5.3 fn:document
14.5.4 fn:collection
14.5.5 fn:input
15 Context Functions
15.1 fn:context-item
15.2 fn:position
15.3 fn:last
15.4 fn:current-dateTime
15.4.1 Examples
15.5 fn:current-date
15.5.1 Examples
15.6 fn:current-time
15.6.1 Examples
15.7 fn:default-collation
15.8 fn:implicit-timezone
16 Casting Functions
16.1 Casting from
primitive types to primitive types
16.2 Casting to
derived types
16.3 Casting
from derived types to parent types
16.4 Casting within a
branch of the type hierarchy
16.5 Casting across
the type hierarchy
16.6 Casting from string
and anySimpleType
16.7 Casting to string and
anySimpleType
16.8 Casting to numeric
types
16.9 Casting
to duration and date and time types
16.10 Casting to
boolean
16.11 Casting to base64Binary and
hexBinary
16.12 Casting to
anyURI
16.13 Casting to
NOTATION
Appendices
XQuery 1.0 and XPath 2.0 Functions and Operators