DTB

From RIF
Revision as of 22:34, 21 April 2008 by AxelPolleres (Talk | contribs)

Jump to: navigation, search

__NUMBEREDHEADINGS__


Document title:
RIF Data Types and Built-Ins (Second Edition)
Editors
Axel Polleres, DERI
Harold Boley, NRC
Abstract
Status of this Document
rough draft

Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.


This document, developed by the Rule Interchange Format (RIF) Working Group, specifies a list of primitive datatypes, built-in functions and built-in predicates supported by the RIF Basic Logic Dialect. Some of the RIF supported datatypes are adopted from XML Schema Part 2: Datatypes Second Edition. A large part of the definitions of the listed functions and operators are adapted from XQuery 1.0 and XPath 2.0 Functions and Operators.

The current version of this document is merely a list of allowed datatypes, built-in functions and built-in predicates to be supported in RIF implementations. In future versions, it is planned to move some of the definitions regrading built-ins, currently located in the RIF Basic Logic Dialect, and RIF Framework for Logic Dialects documents here.

1 Naming and notational conventions used in this document

Throughout this document we use the following prefixes for symbol spaces:

  • the xsd: prefix stands for the XML Schema namespace URI http://www.w3.org/2001/XMLSchema#,
  • the err: prefix stands for http://www.w3.org/2005/xqt-errors/,
  • the rdf: prefix stands for http://www.w3.org/1999/02/22-rdf-syntax-ns#,
  • the rif: prefix stands for http://www.w3.org/2007/rif#,

Syntax such as xsd:string should be understood as a compact URI [CURIE] -- a macro that expands to a concatenation of the character sequence denoted by the prefix xsd and the string string. The compact URI notation is not part of the RIF syntax, but rather just a space-saving device employed in this document.


2 Symbol Spaces and Data Types

2.1 Symbol Spaces

Definition (Symbol space). A symbol space is a named subset of the set of all constants, Const. The semantic aspects of symbol spaces are described in Section Semantic Framework. Each symbol in Const belongs to exactly one symbol space.

Each symbol space has an associated lexical space, a unique identifier, and, possibly, one or more aliases. More precisely,

  • The lexical space of a symbol space is a non-empty set of Unicode character strings.
  • The identifier of a symbol space is a sequence of Unicode characters that form an absolute IRI.
  • An alias is also a sequence of unicode characters, but it is not required to form an IRI.
  • Different symbol spaces cannot share the same identifier or an alias.

The identifiers and aliases of symbol spaces are not themselves constant symbols in RIF.   ☐

To simplify the language, we will often use symbol space identifiers to refer to the actual symbol spaces (for instance, we may use "symbol space xsd:string" instead of "symbol space identified by xsd:string").

To refer to a constant in a particular RIF symbol space, we use the following presentation syntax:

     "literal"^^symspace

where literal is called the lexical part of the symbol, and symspace is an identifier or an alias of the symbol space. Here literal is a sequence of Unicode characters that must be an element in the lexical space of the symbol space symspace. For instance, "1.2"^^xsd:decimal and "1"^^xsd:decimal are legal symbols because 1.2 and 1 are members of the lexical space of the XML Schema data type xsd:decimal. On the other hand, "a+2"^^xsd:decimal is not a legal symbol, since a+2 is not part of the lexical space of xsd:decimal.

The set of all symbol spaces that partition Const is considered to be part of the logic language of RIF-FLD.


RIF requires that all dialects include the following symbol spaces. Rule sets that are exchanged through RIF can use additional symbol spaces.

  • xsd:string (http://www.w3.org/2001/XMLSchema#string)

and all the symbol spaces that correspond to the subtypes of xsd:string as specified in [XML-SCHEMA2].

  • xsd:decimal (http://www.w3.org/2001/XMLSchema#decimal)

and all the symbol spaces that corresponds to the subtypes of xsd:decimal as specified in [XML-SCHEMA2].

  • xsd:time (http://www.w3.org/2001/XMLSchema#time).
  • xsd:date http://www.w3.org/2001/XMLSchema#date).
  • xsd:dateTime http://www.w3.org/2001/XMLSchema#dateTime).


The lexical spaces of the above symbol spaces are defined in the document [XML-SCHEMA2].

  • rdf:XMLLiteral (http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral).

This symbol space represents XML content. The lexical space of rdf:XMLLiteral is defined in the document [RDF-CONCEPTS].

  • rif:text (for text strings with language tags attached).

This symbol space represents text strings with a language tag attached. The lexical space of rif:text is the set of all Unicode strings of the form ...@LANG, i.e., strings that end with @LANG where LANG is a language identifier as defined in [RFC-3066].

  • rif:iri (for internationalized resource identifiers or IRIs).

Constant symbols that belong to this symbol space are intended to be used in a way similar to RDF resources [RDF-SCHEMA]. The lexical space consists of all absolute IRIs as specified in [RFC-3987]; it is unrelated to the XML primitive type anyURI. A rif:iri constant must be interpreted as a reference to one and the same object regardless of the context in which that constant occurs.

  • rif:local (for constant symbols that are not visible outside of the RIF document in which they occur).

Symbols in this symbol space are local to the RIF documents in which they occur. This means that occurrences of the same rif:local constant in different documents are viewed as unrelated distinct constants, but occurrences of the same rif:local constant in the same document must refer to the same object. The lexical space of rif:local is the same as the lexical space of xsd:string.

  • err:. This symbol space represents errors as defined in http://www.w3.org/2005/xqt-errors/ and has as lexical space all the strings FOER0000 - XQST0093 defined in that document.

2.2 Data Types

Data types in RIF are symbol spaces which have special semantics. That is, each datatype is characerized by a fixed lexical space, value space and lexical-to-value-mapping.

Definition (Primitive data type). A primitive data type (or just a data type, for short) is a symbol space that has

  • an associated set, called the value space, and
  • a mapping from the lexical space of the symbol space to the value space, called lexical-to-value-space mapping.   ☐

Semantic structures are always defined with respect to a particular set of data types, denoted by DTS. In a concrete dialect, DTS always includes the data types supported by that dialect. All RIF dialects must support the following primitive data types:

  • xsd:long
  • xsd:integer
  • xsd:decimal
  • xsd:string
  • xsd:time
  • xsd:dateTime
  • rdf:XMLLiteral
  • rif:text
  • err:

Their value spaces and the lexical-to-value-space mappings are defined as follows:

  • For the XML Schema data types of RIF, namely xsd:long, xsd:integer, xsd:decimal, xsd:string, xsd:time, and xsd:dateTime, the value spaces and the lexical-to-value-space mappings are defined in the XML Schema specification [XML-SCHEMA2].
  • The value space and lexical-to-value-space mapping for the primitive data type rdf:XMLLiteral is defined in RDF [RDF-CONCEPTS].
  • The value space rif:text is the set of all pairs of the form (string, lang), where string is a Unicode character sequence and lang is a lowercase Unicode character sequence which is a natural language identifier as defined by [RFC-3066]. The lexical-to-value-space mapping of rif:text, denoted Lrif:text, maps each symbol string@lang in the lexical space of rif:text to (string, lower-case(lang)), where lower-case(lang) is lang written in all-lowercase letters.

The value space and the lexical-to-value-space mapping for rif:text defined here are compatible with RDF's semantics for strings with named tags [RDF-SEMANTICS].

  • The value space of err: is distinct from all the value spaces of other datatypes and th lexical-to-value mapping comprisises of a bijection to distinct values "0FOER0000"^^err: - "XQST0093"^^err: for each error code.

3 Syntax and Semantics of Built-ins

External built-in functions and predicates supported by RIF, form a coherent set of external schemas, as defined in the RIF Framework for Logic Dialects.

3.1 Syntax of Built-ins

Syntactically, built-in predicates and functions are denoted by external terms of the form:

  'External' '(' Expr ')'

where Expr is a UNITERM as defined in in RIF's presentation syntax. For the corresponding normative XML Syntax, see RIF's XML Serialization Framework


3.2 Semantics of Built-ins

The semantics of Built-in functions and predicates within a RIF dialect is defined via a coherent set of external schemas. Each of these external schemas has an associated, external function, which is fixed for all Semantic Structures in the dialect of discourse.

For every external schema, σ, associated with the language, Iexternal(σ) is assumed to be specified externally in some document. In particular, the present document specifies the coherent set ΣBLD of external schemas the BLD dialect along with fixed interpretations

  • Iexternal(σ): D*D for each σ ε ΣBLD such that σ is a builtin function, and
  • Iexternal(σ) D*TV for each σ ε ΣBLD such that σ is a builtin predicate.

Additionally, we assume that in each BLD Semantic structure <TV, DTS, D, Dind, Dfunc, IC, IV, IF, Iframe, ISF, Isub, Iisa, I=, Iexternal, Itruth> it must hold that Dind is a superset of all the value spaces of the primitive datatypes defined in Section Datatypes above.

Editor's comment: we have to assume this for all BLD interpretations, otherwise we cannot define the external built-ins via value spaces of the XSD datatypes.

Other logical dialects are expected to extend this basic set of schemas.

Instead of a two-step interpretation for builtin-predicates Itruth ο (Iexternal(σ)) (the composition of Itruth and Iexternal(σ), a truth-valued function), we defined a single Interpretation, Iexternal(σ) D*TV here.

4 List of Supported Built-in Predicates and Functions

RIF compliant systems have to support the of builtin predicates und functions accordign to the following schemas. The list of several of these functions and predicates overlaps with the functions and predicates (also called operators) defined in XQuery 1.0 and XPath 2.0 Functions and Operators and unless stated otherwise we refer to the definitions therein for the concrete semantics of of the respective built-ins.

4.1 Guard Predicates for Datatypes

RIF requires guard predicates for all its supported datatypes. The schemas for these predicates have the general form

( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDATATYPE"^^rif:iri ( ?arg1 ) )

with Iexternal( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDATATYPE"^^rif:iri ( ?arg1 ) )(s1) = t if and only if s1 is in the value space of DATATYPE and f otherwise. Accordingly, the following schemas are defined:

 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isLong"^^rif:iri ( ?arg1 ) )
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isInteger"^^rif:iri( ?arg1 ) )
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDecimal"^^rif:iri ( ?arg1 ) )
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isString"^^rif:iri ( ?arg1 ) )
 ( ?arg1;  "http://www.w3.org/2007/rif-builtin-predicates#isTime^^rif:iri ( ?arg1 ) )
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDateTime"^^rif:iri ( ?arg1 ) )
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isXMLLiteral"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isText"^^rif:iri ( ?arg1 ) )

Likewise, RIF has negative guards for all its supported datatypes. These builtin predicates have the schema

( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDATATYPE"^^rif:iri ( ?arg1 ) )

with Iexternal( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDATATYPE"^^rif:iri ( ?arg1 ) )(s1) = f if and only if s1 is in the value space of DATATYPE and t otherwise. Accordingly, the following schemas are defined:


 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotLong"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotInteger"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDecimal"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotString"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotTime"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDateTime"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotXMLLiteral"^^rif:iri ( ?arg1 ) ) 
 ( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotText"^^rif:iri ( ?arg1 ) )

Future dialects may extend this list of guards to other datatypes, but RIF does not require guards for all datatypes.

4.2 Cast functions for Datatypes and rif:iri

RIF requires cast functions for all its supported datatypes, i.e.

( ?arg1; "DATATYPE"^^rif:iri ( ?arg1 ) )

where DATATYPE is one of the primitive data types defined in Section []

Iexternal( ?arg1; "DATATYPE"^^rif:iri ( ?arg1 ) )(s1) = s1'

such that s1' is the conversion of s1 to the value space of xsd:DATATYPE if and only if conversion from s1 is possible according to the table in Section 17.1 of XQuery 1.0 and XPath 2.0 Functions and Operators, and err:XPTY0004 otherwise.

Partial conversion functions between the datatypes xsd:time, xsd:string, xsd:dateTime are defined as in the conversion table in Section 17.1 of XQuery 1.0 and XPath 2.0 Functions and Operators.

Note that neither the three remaining data types xsd:long, rif:XMLLiteral, and err:, nor the symbl space rif:iri do not appear in that table, but the following considerations apply:

  • The conversions from and to xsd:long follow the same considerations as xsd:integer in that table, by the XPath, XQuery type hierarchy in Section 1.6 of XQuery 1.0 and XPath 2.0 Functions and Operators.
  • Any rif:XMLLiteral can be cast to xsd:string by preserving the lexical value and just changing the symbol space. An xsd:string can be cast to rdf:XMLLiteral if and only if its value is in the lexical space of rdf:XMLLiteral as defined in Resource Description Framework (RDF): Concepts and Abstract Syntax.
  • Any rif:text can be cast to xsd:string by preserving the lexical value of its string part.
  • Any err: can be cast to xsd:string by preserving its lexical value.
  • Additionally we allow conversions from and to rif:iri following the same considerations as conversions from and to xsd:anyURI.

Although rif:iri is not a datatype, I left conversions from and to rif:iris in the list of cast functions, since I see some use cases in the context of RDF if you want to extract a string from an IRI and vice versa. See also the use case mentioned in http://lists.w3.org/Archives/Public/public-rif-wg/2008Mar/0011.html

4.3 Functions and Operators on Numerics

If not stated otherwise, in the following we define schemas for functions and operators defined on the numeric datatypes in XML Schema Part 2: Datatypes Second Edition.

4.3.1 Functions on Numeric Values

1. op:numeric-add

(?arg1 ?arg2; func:numeric-add( ?arg1 ?arg2) )

where Iexternal( ?arg1 ?arg2; func:numeric-add( ?arg1 ?arg2 ) )(s1 s2) = res

such that res is the result of op:numeric-add(s1, s2) as defined in XQuery 1.0 and XPath 2.0 Functions and Operators if both arguments are numeric (i.e. their interpretation is in the value space of xsd:integer, xsd:long, or xsd:decimal), otherwise returns an error as defined in XQuery 1.0 and XPath 2.0 Functions and Operators. The following schemata are defined analogously with respect to their corresponding function and possible error codes as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

2. op:numeric-subtract

(?arg1 ?arg2; func:numeric-subtract( ?arg1 ?arg2) )

3. op:numeric-multiply

(?arg1 ?arg2; func:numeric-multiply( ?arg1 ?arg2) )

4. op:numeric-divide

(?arg1 ?arg2; func:numeric-divide( ?arg1 ?arg2) )

4.3.2 Predicates on Numeric Values

1. op:numeric-equal

 (?arg1 ?arg2; pred:numeric-equal( ?arg1 ?arg2) )

where Iexternal( ?arg1 ?arg2; pred:numeric-equal ?arg1 ?arg2 ) )(s1 s2) = t

if and only if op:numeric-equal(s1, s2) returns true, as defined in XQuery 1.0 and XPath 2.0 Functions and Operators, f otherwise. The following schemata are defined analogously with respect to their corresponding operators as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

Shall we return false or error for mistypes in predicates? The corresponding XPath operator would throw an error on mistyping. Depends on final decision on error handling.

2. op:numeric-less-than

(?arg1 ?arg2; pred:numeric-less-than( ?arg1 ?arg2) )

3. op:numeric-less-than

(?arg1 ?arg2; pred:numeric-greater-than( ?arg1 ?arg2) )

4.4 Functions and Predicates on Strings

If not stated otherwise, in the following we define schemas for functions and operators defined on strings in XML Schema Part 2: Datatypes Second Edition.


Issue: In the following, we often encounter several versions of some built-ins. Since XPath and Xquery allow overloading, i.e. the same function or operator name occurring with different arities. We suggest to treat this likewise in RIF, by numbering the different versions of the respective built-ins and treating the unnumbered version as syntactic sugar, i.e. for instance instead of External( func:concat2( str1, str2) ) and </tt>External( func:concat3( str1 str2 str3 ) )</tt> we equally allow simply to write External( func:concat( str1, str2) ) and </tt>External( func:concat( str1 str2 str3 ) )</tt>. Note that this is really purely syntactic sugar, and does not mean that for external predicates and functions we lift restriction that each function and presidcate has a unique assigned arity. Those schemata for which we allow this syntactic sugar, appear in the same box.

4.4.1 Functions on Strings

1. fn:compare

( ?comparand1 ?comparand2; func:compare1(?comparand1 ?comparand2) )
( ?comparand1 $comparand2 $collation; func:compare2(?comparand1 ?comparand2 ?collation) )

where Iexternal( ( ?comparand1 ?comparand2; func:compare1(?comparand1 ?comparand2) )(s1 s2) = res

such that res = -1, 0, or 1, depending on whether the value of the s1 is respectively less than, equal to, or greater than the value of s2, according to the rules of the collation that is used.


2. fn:concat

( ?arg1; func:concat1(1 ) )
( ?arg1 ?arg2; func:concat2(?arg1 ?arg2 ) )
...
( ?arg1  ?arg2 ... ?argn; func:concatn(?arg1 ?arg2 ... ?argn ) )

Accepts xs:anyAtomicType arguments and casts them to xsd:string. Returns the xsd:string that is the concatenation of the values of its arguments after conversion. Only defined if all arguments are castable to strings (see Section on Cast functions above), otherwise returns an error as defined for fn:concat.

2. fn:string-join

( ?arg1 ?arg2; func:string-join2(?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?arg3; func:string-join2(?arg1 ?arg2 ?arg3 ) )
...
( ?arg1  ?arg2 ... ?argn; func:string-joinn(?arg1 ?arg2 ... ?argn ) )

Returns a xsd:string created by concatenating the arguments 1 to (n-1) using the nth argument as a separator. Only defined if all arguments are strings, otherwise returns an error as defined for fn:string-join.

3. fn:substring

( ?sourceString� ?startingLoc; fn:substring1( ?sourceString� ?startingLoc) )
( fn:substring2( ?sourceString ?startingLoc ?length) )

Returns the portion of the value of ?sourceString beginning at the position indicated by the value of ?startingLoc and continuing for the number of characters indicated by the value of ?length. The characters returned do not extend beyond ?sourceString. If ?startingLoc is zero or negative, only those characters in positions greater than zero are returned.

4. fn:string-length

( func:string-length1() )
( ?arg ; func:string-length2( ?arg ) )

Returns an xsd:integer equal to the length in characters of the argument if it is a xsd:string.

5. fn:upper-case

( ?arg ; func:upper-case( ?arg ) )

6. fn:lower-case

( ?arg ; func:lower-case( ?arg ) )

7. fn:encode-for-uri

( ?arg ; func:encode-for-uri( ?arg ) )

This function encodes reserved characters in an xs:string that is intended to be used in the path segment of a URI. It is invertible but not idempotent.

8. fn:iri-to-uri

( ?iri ; func:iri-to-uri ( ?iri ) )

9. fn:escape-html-uri

( ?uri ;func:escape-html-uri( ?uri ) )

This function escapes all characters except printable characters of the US-ASCII coded character set, specifically the octets ranging from 32 to 126 (decimal). The effect of the function is to escape a URI in the manner html user agents handle attribute values that expect URIs. Each character in $uri to be escaped is replaced by an escape sequence, which is formed by encoding the character as a sequence of octets in UTF-8, and then representing each of these octets in the form %HH, where HH is the hexadecimal representation of the octet. This function must always generate hexadecimal values using the upper-case letters A-F.

10. fn:substring-before

( ?arg1 ?arg2; func:substring-before1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation; func:substring-before2( ?arg1 ?arg2 ?collation ) )

11. fn:substring-after

( ?arg1 ?arg2; func:substring-after1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation; func:substring-after2( ?arg1 ?arg2 ?collation ) )

12. fn:replace

( ?input ?pattern ?replacement; func:replace1( ?input ?pattern ?replacement ) )
( ?input ?pattern ?replacement ?flags; func:replace2( ?input ?pattern ?replacement ?flags ) )

Editor's note: I removed fn:tokenize from previous versions, since tokenizer returns a sequence of strings, we might reconsider this if we (re-)introduce lists, but I left this out for the moment.

4.4.2 Predicates on Strings

The predicates described here examine the first string argument to see whether it contains the second string argument as a substring.

1. fn:contains

( ?arg1 ?arg2; pred:contains1( ?arg1 ?arg2 ) ) 
( ?arg1 ?arg2 ?collation ; pred:contains2( ?arg1 ?arg2 ?collation ) )

Returns true or false indicating whether or not the value of $arg1 contains (at the beginning, at the end, or anywhere within) at least one sequence of collation units that provides a minimal match to the collation units in the value of $arg2, according to the collation that is used. "Minimal match" is defined in Unicode Collation Algorithm.

Shall we return an error or false on typing errors?

2. fn:starts-with

( ?arg1 ?arg2; pred:starts-with1( ?arg1 ?arg2 )
( ?arg1 ?arg2 ?collation; pred:starts-with2( ?arg1 ?arg2 ?collation)

Shall we return an error or false on typing errors?

3. fn:ends-with

(?arg1 ?arg2; fn:ends-with1( ?arg1 ?arg2 ) )
(?arg1 ?arg2 ?collation; fn:ends-with2( ?arg1 ?arg2 ?collation) )

Shall we return an error or false on typing errors?

4. fn:matches

( ?input ?pattern; pred:matches1( ?input ?pattern) )
( ?input ?pattern ?flags; pred:matches2( ?input ?pattern ?flags ) )

The function returns true if the input matches the regular expression supplied as pattern as influenced by the flags, if present; otherwise, it returns false.

The effect of calling the first version of this function (omitting the flags) is the same as the effect of calling the second version with the flags argument set to a zero-length string.

Shall we return an error or false on typing errors?

4.5 Functions and Predicates on Dates and Times

If not stated otherwise, in the following we define schemas for functions and operators defined on the date and time datatypes in XML Schema Part 2: Datatypes Second Edition.

As defined in Section 3.3.2 Dates and Times, xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth, xsd:gYear, xsd:gMonthDay, xsd:gMonth, xsd:gDay values, referred to collectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, second and timezone. The value of the first five components are xsd:integers. The value of the second component is an xsd:decimal and the value of the timezone component is an xsd:dayTimeDuration. For all the date/time datatypes, the timezone property is optional and may or may not be present. Depending on the datatype, some of the remaining six properties must be present and some must be absent. Absent, or missing, properties are represented by the empty sequence. This value is referred to as the local value in that the value is in the given timezone. Before comparing or subtracting xsd:dateTime values, this local value must be translated or normalized to UTC.


4.5.1 Predicates on Date and Time Values

1. op:dateTime-equal

( ?arg1 ?arg2; pred:dateTime-equal( ?arg1 ?arg2) )

where Iexternal( ?arg1 ?arg2; pred:dateTime-equal( ?arg1 ?arg2 ) )(s1 s2) = t

if and only if op:dateTime-equal(s1, s2) returns true, as defined in XQuery 1.0 and XPath 2.0 Functions and Operators, f otherwise. The following schemata are defined analogously with respect to their corresponding operators as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.

2. op:dateTime-less-than

( ?arg1 ?arg2; pred:dateTime-less-than(?arg1 ?arg2 ) )


3. op:dateTime-greater-than

( ?arg1 ?arg2; pred:dateTime-greater-than(?arg1 ?arg2 ) )

4. op:date-equal

( ?arg1 ?arg2; pred:date-equal( ?arg1 ?arg2) )

5. op:date-less-than

( ?arg1 ?arg2; pred:date-less-than(?arg1 ?arg2 ) )

6. op:date-greater-than

( ?arg1 ?arg2; pred:date-greater-than(?arg1 ?arg2 ) )

7. op:time-equal

( ?arg1 ?arg2; pred:time-equal( ?arg1 ?arg2) )

8. op:time-less-than

( ?arg1 ?arg2; pred:time-less-than(?arg1 ?arg2 ) )

9. op:time-greater-than

( ?arg1 ?arg2; pred:time-greater-than(?arg1 ?arg2 ) )

4.5.2 Functions on Dates and Times

1. fn:year-from-dateTime

( ?arg ; func:year-from-dateTime( ?arg ) )

where Iexternal( ?arg ; func:year-from-dateTime( ?arg ) )(s) = res

such that res is the result of fn:year-from-dateTime(s) as defined in XQuery 1.0 and XPath 2.0 Functions and Operators if s is in the value space of xsd:dateTime, otherwise returns an error as defined in XQuery 1.0 and XPath 2.0 Functions and Operators. The following schemata are defined analogously with respect to their corresponding functions and possible error codes as defined in XQuery 1.0 and XPath 2.0 Functions and Operators.


Editor's remark: Where in XQuery 1.0 and XPath 2.0 Functions and Operators are the errors for these functions defined?

We slightly deviate here from the original definition of fn:year-from-dateTime which says: "If ?arg is the empty sequence, returns the empty sequence." We have no terminology of "sequence".

Editor's remark: I am not sure whether this is a problem. Do we have to deal with empty sequences?

2. fn:month-from-dateTime

( ?arg ; func:month-from-dateTime( ?arg ) )

3. fn:day-from-dateTime

( ?arg ; func:day-from-dateTime( ?arg ) )

4. fn:hours-from-dateTime

( ?arg ; func:hours-from-dateTime( ?arg ) )

5. fn:minutes-from-dateTime

( ?arg ; func:minutes-from-dateTime( ?arg  ) )

6. fn:seconds-from-dateTime

( ?arg ; func:seconds-from-dateTime( ?arg ) )

7. fn:year-from-date

( ?arg ; func:year-from-date( ?arg ) )

8. fn:month-from-date

( ?arg ; func:month-from-date( ?arg ) )

9. fn:day-from-date

( ?arg ; func:day-from-date( ?arg ) )

10. fn:hours-from-time

( ?arg ; func:hours-from-time( ?arg ) )

11. fn:minutes-from-time

( ?arg ; func:minutes-from-time( ?arg ) )

12. fn:seconds-from-time

( ?arg ; func:seconds-from-time( ?arg ) )

4.6 Functions and Predicates on rif:XMLLiterals

We support (though not impose) an XPath built-in function, applied to XMLLiterals as follows.

(?xml ?xquery; func:evalXQuery( ?xml ?xquery) )

where Iexternal(?xml ?xquery; func:evalXQuery( ?xml ?xquery) )(s1 s2) = res such that, if s1 is in the value space of rdf:XMLLiteral and s2 is in the value space of xsd:string and s2 is a syntactically valid XQuery expression, then res is the result of the XQuery s2 on the context item being the root node of the XML document represented by s1, and otherwise if no other error as defined in XQuery applies, the error err:XQTY0028.

Editor's remark: The error code err:XQTY0028 is currently unused.

4.7 Functions and Predicates on rif:text

(?arg ; func:lang( ?arg ) )

where Iexternal(?arg ; func:lang( ?arg ) )(s) = res such that res is the language tag string of s, if s is in the value space of rif:text and ""^^xsd:string otherwise.

5 References

[RDF-CONCEPTS]
Resource Description Framework (RDF): Concepts and Abstract Syntax, Klyne G., Carroll J. (Editors), W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/. Latest version available at http://www.w3.org/TR/rdf-concepts/.

[RDF-SEMANTICS]
RDF Semantics, Patrick Hayes, Editor, W3C Recommendation, 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-mt-20040210/. Latest version available at http://www.w3.org/TR/rdf-mt/.

[RDF-SCHEMA]
RDF Vocabulary Description Language 1.0: RDF Schema, Brian McBride, Editor, W3C Recommendation 10 February 2004, http://www.w3.org/TR/rdf-schema/.

[RFC-3066]
RFC 3066 - Tags for the Identification of Languages, H. Alvestrand, IETF, January 2001. This document is at http://www.isi.edu/in-notes/rfc3066.txt.

[RFC-3987]
RFC 3987 - Internationalized Resource Identifiers (IRIs), M. Duerst and M. Suignard, IETF, January 2005. This document is at http://www.ietf.org/rfc/rfc3987.txt.

[XML-SCHEMA2]
XML Schema Part 2: Datatypes, W3C Recommendation, World Wide Web Consortium, 2 May 2001. This version is http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/. The latest version is available at http://www.w3.org/TR/xmlschema-2/.