W3C


RIF Datatypes and Built-Ins 1.0

W3C Editor's Draft 22 September21 November 2008

This version:
http://www.w3.org/2005/rules/wg/draft/ED-rif-dtb-20080922/http://www.w3.org/2005/rules/wg/draft/ED-rif-dtb-20081121/
Latest editor's draft:
http://www.w3.org/2005/rules/wg/draft/rif-dtb/
Previous version:
http://www.w3.org/2005/rules/wg/draft/ED-rif-dtb-20080730/http://www.w3.org/2005/rules/wg/draft/ED-rif-dtb-20080922/ (color-coded diff)
Editors:
Axel Polleres, DERI
Harold Boley, National Research Council Canada
Michael Kifer, State University of New York at Stony Brook


Abstract

Status of this Document

May Be Superseded

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document is being published as one of a set of 85 documents:

  1. RIF Use Cases and Requirements
  2. RIF Core
  3. RIF Basic Logic Dialect RIF Framework for Logic Dialects RIF RDF and OWL Compatibility RIFDatatypes and Built-Ins 1.0 (this document)
  4. RIF Production Rule Dialect
  5. RIF (Rule Interchange Format) Test Cases

Please Comment By 2008-09-252008-11-25

The Rule Interchange Format (RIF) Working Group seeks public feedback on these Working Drafts. Please send your comments to public-rif-comments@w3.org (public archive). If possible, please offer specific changes to the text that would address your concern. You may also wish to check the Wiki Version of this document for internal-review comments and changes being drafted which may address your concerns.

No Endorsement

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Patents

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.



This document, developed by the Rule Interchange Format (RIF) Working Group, specifies a list of primitive datatypes, built-in functions and built-in predicates expected to be supported by RIF dialects such as the RIF Basic Logic Dialect. Each dialect supporting a superset or subset of the primitive datatypes, built-in functions and built-in predicates defined here shall specify these additions or restrictions. Some of the datatypes are adopted from [XML-SCHEMA2]. A large part of the definitions of the listed functions and operators are adaptedadopted from [XPath-Functions]. The rdf:text datatype as well as functions and operators associated with that datatype are adopted from [RDF-TEXT].


Contents

1 Constants, Symbol Spaces, and Datatypes

1.1 Constants and Symbol Spaces

Each constant (that is, each non-keyword symbol) in RIF belongs to a particular symbol space. A constant in a particular RIF symbol space has the following presentation syntax:

""literal "^^<"^^<symbolSpaceIri>

where literal is called the lexical part of the symbol, and symbolSpaceIri is an (absolute or relative) IRI identifying the symbol space. Here literal is a Unicode string that must be an element in the lexical space of the symbol space identified by the IRI symbolSpaceIri.

1.2 The Base and Prefix Directives

Since IRI typically require long strings of characters, many Web languages have special provisions for abbreviating these strings. One popular technique is called compact URI [CURIE], and RIF uses a similar technique by allowing RIF documents to have the directives Base and Prefix.

The precise way in which these directives work is explained in Section Shortcuts for Constants in RIF's Presentation Syntax.

To avoid writing down long IRIs, this document will assume that the following Prefix directives have been specified in all the RIF documents under consideration:

Using these prefixes and the shorthand mechanism defined in Section Shortcuts for Constants in RIF's Presentation Syntax, we can, for example, abbreviate a constant such as "http://www.example.org"^^<http://www.w3.org/2007/rif#iri>"http://www.example.org"^^<http://www.w3.org/2007/rif#iri> into "http://www.example.org"^^rif:iri"http://www.example.org"^^rif:iri.

1.2.1 Symbol Spaces

Formally, we define symbol spaces as follows.

Definition (Symbol space). A symbol space is a named subset of the set of all constants, Const in RIF. Each symbol in Const belongs to exactly one symbol space.

Each symbol space has an associated lexical space and a unique IRI identifying it. More precisely,

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

For convenience we will often use symbol space identifiers to refer to the actual symbol spaces (for instance, we may use "symbol"symbol space xs:string "" instead of "symbol"symbol space identified by xs:string ").").


RIF dialects are expected to include the following symbol spaces. However, rule sets that are exchanged through RIF can use additional symbol spaces.

Note that, by the associated lexical space, not all unicode strings are syntactically valid lexical parts for all symbol spaces. That is, for instance "1.2"^^xs:decimal"1.2"^^xs:decimal and "1"^^xs:integer"1"^^xs:integer are syntactically valid constant because 1.2 and 1 are members of the lexical space of symbol spaces xs:decimal and xs:integer, respectively. On the other hand, "a+2"^^xs:decimal"a+2"^^xs:decimal is not a syntactically valid constant, since a+2 is not part of the lexical space of xs:decimal.

We will often refer to constant symbols that come from a particular symbol space, X, as X-constants. For instance the constants in the symbol space rif:iri will be referred to as IRI constants or rif:iri constants and the constants found in the symbol space rif:local as local constants or rif:local constants.


1.2.2 Shortcuts for Constants in RIF's Presentation Syntax

Besides the basic notion

""literal "^^<"^^<identifier>

RIF's presentation syntax introduces several shortcuts for particular symbol spaces, in order to make the presentation syntax more readable. RIF's presentation syntax for constants is defined by the following EBNF.

  ANGLEBRACKIRI::= IRI_REF
  SYMSPACE     ::= ANGLEBRACKIRI | CURIE
  CURIE        ::= PNAME_LN | PNAME_NS
  Const        ::=  '"''"' UNICODESTRING  '"^^''"^^' SYMSPACE | CONSTSHORT
  CONSTSHORT   ::= ANGLEBRACKIRI              // shortcut for  "..."^^rif:iri"..."^^rif:iri
                  | CURIE                      // shortcut for  "..."^^rif:iri"..."^^rif:iri
                  |  '"''"' UNICODESTRING  '"''"'      // shortcut for  "..."^^xs:string"..."^^xs:string
                  | NumericLiteral             // shortcut for  "..."^^xs:integer,xs:decimal,xs:double"..."^^xs:integer,xs:decimal,xs:double
                  | '_' LocalName              // shortcut for  "..."^^rif:local"..."^^rif:local
                  | '"' UNICODESTRING '"' '@' languageTag             // shortcut for "...@..."^^rdf:text

The EBNF grammar relies on reuse of nonterminals defined in the following grammar productions from other documents:

In this grammar, CURIE stands for compact IRIs [CURIE], which are used to abbreviate symbol space IRIs. For instance, one can write "http://www.example.org"^^rif:iri"http://www.example.org"^^rif:iri instead of "http://www.example.org"^^<http://www.w3.org/2007/rif#iri>"http://www.example.org"^^<http://www.w3.org/2007/rif#iri>, where rif is a prefix defined in Section Base and Prefix Directives. <p>Apart from compact IRIs, there exist convenient shortcut notations for constants in specific symbol spaces, namely for constants in the symbol spaces rif:iri, xs:string, xs:integer, xs:decimal, xs:double, and rif:local:

Editor's Note: We might introduce additional shortcuts, e.g. for rif:text in future versions of this draft.1.2.3 Relative IRIs

Relative IRIs in RIF documents are resolved with respect to the base IRI. Relative IRIs are combined with base IRIs as per Uniform Resource Identifier (URI): Generic Syntax [RFC-3986] using only the basic algorithm in Section 5.2. Neither Syntax-Based Normalization nor Scheme-Based Normalization (described in sections 6.2.2 and 6.2.3 of RFC-3986) are performed. Characters additionally allowed in IRI references are treated in the same way that unreserved characters are treated in URI references, per section 6.5 of Internationalized Resource Identifiers (IRIs) [RFC-3987].

Base IRIs are specified using the Base directive described in Section Base and Prefix Directives. At most one base directive per document is allowed. In the XML syntax, base IRIs are specified using the attribute xml:base.

For instance, the constant <./xyz> or "./xyz"^^rif:iri"./xyz"^^rif:iri are both valid abbreviations in RIF for the constant http://www.example.org/xyz"^^rif:irihttp://www.example.org/xyz"^^rif:iri, if the following directive is present in the document:

Base(http://www.example.org)

1.3 Primitive Datatypes

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

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

Semantic structures are always defined with respect to a particular set of datatypes, denoted by DTS. In a concrete dialect, DTS always includes the datatypes supported by that dialect. RIF dialects are expected to support the following primitive datatypes. However, RIF dialects may include additional datatypes.

rif:text Editor's Note: rif:text (in particular, its identifying IRI) is an AT RISK feature. We expect a joint effort with the OWL WG to discuss rif:text and the equivalent OWL datatype, striving for a uniform symbol space for such text strings with a language tag.Their value spaces and the lexical-to-value-space mappings are defined as follows:

Note that the value space and the lexical-to-value-space mapping for rif:textrdf:text defined here are compatible with RDF's semantics for stringsstring literals with named tags [RDF-SEMANTICS]. Moreover, the value space and the lexical-to-value-space mapping for xs:string are compatible with RDF's semantics for plain literals. RIF implementations MAY choose to interpret xs:string and its subtypes as subtypes of rdf:text following Section 3.1 of [RDF-TEXT], i.e., interpreting strings as texts with an empty language tag.

Editor's Note: Whether or not we allow the treatment of xs:string as a subtype of rdf:text in RIF implementations is still under discussion, cf. the mail thread starting at http://lists.w3.org/Archives/Public/public-rif-wg/2008Nov/0067.html.

2 Syntax and Semantics of Built-ins

2.1 Syntax of Built-ins

A RIF built-in function or predicate is a special case of externally defined terms, which are defined in RIF Framework for Logic Dialects and also reproduced in the direct definition of RIF Basic Logic Dialect (RIF-BLD).

In RIF's presentation syntax built-in predicates and functions are syntactically represented as external terms of the form:

'External' '(' Expr ')'

where Expr is a positional term as defined in RIF Framework for Logic Dialects (see also in RIF Basic Logic Dialect). For RIF's normative syntax, see the XML Serialization Framework in RIF-FLD, or, specifically for RIF-BLD, see XML Serialization Syntax for RIF-BLD.

RIF-FLD introduces the notion of an external schema to describe both both the syntax and semantics of exernally defined terms. In the special case of a RIF built-in, external schemas have an especially simple form. A built-in named f that takes n arguments has the schema

(?X1 ...?Xn; f(?X1 ...?Xn) )

Here f(?X1 ...?Xn) is the actual term that is used to refer to the built-in (in expressions of the form External(f(?X1 ...?Xn))) and ?X1 ...?Xn is the list of all variables in that term.

For convenience, a complete definition of external schemas is reproduced in Appendix: Schemas for Externally Defined Terms.


2.2 Semantics of Built-ins

The semantics of external terms in RIF-FLD and RIF-BLD is defined using two mappings: Iexternal and Itruth Iexternal.

3 List of RIF Built-in Predicates and Functions

This section provides a catalogue defining the syntax and semantics of a list of built-in predicates and functions in RIF. For each built-in, the following is defined:

  1. The name of the built-in.
  2. The external schema of the built-in.
  3. For a built-in function, how it maps its arguments into a result.

    As explained in Section Semantics of Built-ins, this corresponds to the mapping Iexternal() in the formal semantics of RIF-FLD and RIF-BLD, where is the external schema of the built-in.

  4. For a built-in predicate, its truth value when the arguments are substituted with values in the domain.

    As explained in Section Semantics of Built-ins, this corresponds to the mapping Itruth Iexternal() in the formal semantics of RIF-FLD and RIF-BLD, where is the external schema of the built-in.

  5. The intended domains for the arguments of the built-in.

    Typically, built-in functions and predicates are defined over the value spaces of appropriate datatypes. These are the intended domains of the arguments. When an argument falls outside of its intended domain, it is understood as an error. Since this document defines a model-theoretic semantics for RIF built-ins, which does not support the notion of an error, the definitions leave the values of the built-in predicates and functions unspecified in such cases. This means that if one or more of the arguments is not in its intended domain, the value of Iexternal()(a1 ... an) can vary from one semantic structure to another. Similarly, Itruth Iexternal()(a1 ... an) can be t in some interpretations and f in others when an argument is not in the intended domain.

    This indeterminacy in case of an error implies that applications must not make any assumptions about the values of built-ins in such situations. Implementations are even allowed to abort in such cases and the only safe way to communicate rule sets that contain built-ins among RIF-compliant systems is to use datatype guards.


Many built-in functions and predicates described below are adapted from [XPath-Functions] and, when appropriate, we will refer to the definitions in that specification in order to avoid copying them.

3.1 Guard Predicates for Datatypes

RIF defines guard predicates for all datatypes in Section Primitive Datatypes.

  • Schema: The schemas for these predicates have the general form

    (?arg1; pred:isDATATYPE (?arg1 ) )

    Here, DATATYPE is the short name for a datatype. As a naming convention we use the capitalized non-prefix XML local name part of the IRI denoting the datatype, for instance we use pred:isString for the guard predicate for xs:string, or pred:isText for the guard predicate for rif:text. Parties defining their own datatypes to be used in RIF exchanged rules may define their own guard predicates for these datatypes. Labels used for such additional guard predicates for datatypes not mentioned in the present document MAY follow the samea similar naming convention where applicable without creating ambiguities with predicate names defined in the present document. Particularly, upcoming W3C specifications MAY - but 3rd party dialects MUST NOT - reuse the pred: namespace for such guard predicates.

    Editor's Note: The naming conventionformulation of the clause on namespace-reuse is under discussion, for guard predicates, particularlyinstance, whether third parties defining their ownwe shall allow guards and negative guards for all of the XML Schema primitive datatypes should be encouraged/discouraged to reuseunder the standardpred: and func: namespaces to define their own built-in predicates and functions, are still under discussion in the working group. Intended domain : Guardnamespace.

  • Intended domain:

    Guard predicates do not depend on a specific intended domain.

  • Mapping:

    Itruth Iexternal(?arg1; pred:isDATATYPE (?arg1 ) )(s1) = t if and only if s1 is in the value space of DATATYPE and f otherwise.

Accordingly, the following schemas are defined.

3.1.1 pred:isInteger

  • Schema:

    (?arg1; pred:isInteger(?arg1 ) )

3.1.2 pred:isDecimal

  • Schema:

    (?arg1; pred:isDecimal (?arg1 ) )

3.1.3 pred:isDouble

  • Schema:

    (?arg1; pred:isDouble (?arg1 ) )

3.1.4 pred:isString

  • Schema:

    (?arg1; pred:isString (?arg1 ) )

3.1.5 pred:isTime

  • Schema:

    (?arg1; pred:isTime (?arg1 ) )

3.1.6 pred:isDate

  • Schema:

    (?arg1; pred:isDate (?arg1 ) )

3.1.7 pred:isDateTime

  • Schema:

    (?arg1; pred:isDateTime (?arg1 ) )

3.1.8 pred:isDayTimeDuration

  • Schema:

    (?arg1; pred:isDayTimeDuration (?arg1 ) )

3.1.9 pred:isYearMonthDuration

  • Schema:

    (?arg1; pred:isYearMonthDuration (?arg1 ) )

3.1.10 pred:isXMLLiteral

  • Schema:

    (?arg1; pred:isXMLLiteral (?arg1 ) )

3.1.11 pred:isText

  • Schema:

    (?arg1; pred:isText (?arg1 ) )

Editor's Note: It was noted in discussionsFuture dialects may extend this list of the working group, that except guard predicates, also an analogous built-in function or predicateguards to SPARQL's datatype function is needed. This however has some technical implications, see http://lists.w3.org/Archives/Public/public-rif-wg/2008Jul/0096.htmlother datatypes, but RIF does not require guards for all datatypes.

3.2 Negative Guard Predicates for Datatypes

Likewise, RIF defines negative guard predicates for all datatypes in Section Primitive Datatypes.

  • Schema: The schemas for negative guards have the general form

    (?arg1; pred:isNotDATATYPE (?arg1 ) )

    Here, DATATYPE is the short name for one of the datatypes mentioned in this document. As a naming convention we use the capitalized non-prefix XML local name part of the IRI denoting the datatype, for instance we use pred:isNotString for the negative guard predicate for xs:string, or pred:isNotText for the negative guard predicate for rif:text. Parties defining their own datatypes to be used in RIF exchanged rules may define their own negative guard predicates for these datatypes. Labels used for such additional negative guard predicates for datatypes not mentioned in the present document MAY follow the samea similar naming convention where applicable without creating ambiguities with predicate names defined in the present document. Editor's Note:Particularly, upcoming W3C specifications MAY, but 3rd party dialects MUST NOT reuse, the naming conventionpred: namespace for such negative guard predicates, particularly whether third parties defining their own datatypes should be encouraged/discouraged to reusepredicates.


    Editor's Note: The standard pred: and func: namespaces to define their own built-in predicatesformulation of the clause on namespace-reuse is under discussion, for instance, whether we shall allow guards and functions, are stillnegative guards for all of the XML Schema primitive datatypes under discussion inthe working group.pred: namespace.

  • Intended domain:

    Negative guard predicates do not depend on a specific intended domain.

  • Mapping:

    Itruth Iexternal(?arg1; pred:isNotDATATYPE (?arg1 ) )(s1) = f if and only if s1 is in the value space of DATATYPE and t otherwise.

Accordingly, the following schemas are defined.

3.2.1 pred:isNotInteger

  • Schema:

    (?arg1; pred:isNotInteger (?arg1 ) )

3.2.2 pred:isNotDecimal

  • Schema:

    (?arg1; pred:isNotDecimal (?arg1 ) )

3.2.3 pred:isNotDouble

  • Schema:

    (?arg1; pred:isNotDouble (?arg1 ) )

3.2.4 pred:isNotString

  • Schema:

    (?arg1; pred:isNotString (?arg1 ) )

3.2.5 pred:isNotTime

  • Schema:

    (?arg1; pred:isNotTime (?arg1 ) )

3.2.6 pred:isNotDate

  • Schema:

    (?arg1; pred:isNotDate (?arg1 ) )

3.2.7 pred:isNotDateTime

  • Schema:

    (?arg1; pred:isNotDateTime (?arg1 ) )

3.2.8 pred:isNotDayTimeDuration

  • Schema:

    (?arg1; pred:isNotDayTimeDuration (?arg1 ) )

3.2.9 pred:isNotYearMonthDuration

  • Schema:

    (?arg1; pred:isNotYearMonthDuration (?arg1 ) )

3.2.10 pred:isNotXMLLiteral

  • Schema:

    (?arg1; pred:isNotXMLLiteral (?arg1 ) )

3.2.11 pred:isNotText

  • Schema:

    (?arg1; pred:isNotText (?arg1 ) )

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

3.3 Cast Functions andDatatype Conversion Predicates for Datatypesand rif:iri RIF defines cast functions for allDatatypes mentioned in this document, i.e. for each datatype with IRI DATATYPEIRI there is an external function with the following schema: Schema : (?arg 1 ; < DATATYPEIRI > (?arg 1 ) ) We now discuss the intended domains and mappings for these cast functions. Editor's Note:Checking

In the following, we adapt several cast functions fromaccording to the conversions defined in Section 17.1 of [XPath-Functions]. Note that some of these conversions are only partially defined, which affects the intended domains of these cast functions.

Editor's Note: Due to the subtle differences in e.g.casting, e.g., concerning error handlinghandling, between RIF and [XPath-Functions], thesethe definitions of cast functions might still need refinement in terms of defining the intended domains in future versions of this draft. Also, the definition of the mappings need refinement.

Likewise we define a conversion predicate useful for converting between rif:iri constants and strings, as well as a predicate to check the datatype of a constant.

3.3.1 xs:double

Editor's Note: We might split this subsection into separate subsections per casting function in future versions of this document, following the convention of having one separate subsection per funtcion/predicate in the rest of the document. However, it seemed convenient here to group the cast functions which purely rely on XML Schema datatype casting into one common subsection.3.3.2 xs:stringxs:integer

Editor's Note: The cast from rif:text to xs:string is still under discussion, i.e. whether the lang tag should be included when casting to xs:string or not.3.3.3 rdf:XMLLiteralxs:decimal

3.3.4 rif:textxs:time

3.3.5 pred:iri-to-string Editor's Note: Conversion from rif:iri to xs:string and vice versa is still under discussion in the working group since rif:iri is not a datatype. For details, we refer to Issue-61 . The following is a strawman proposal which might still change in future versions of this working draft. Conversions from rif:iri to xs:string and vice versa cannot be defined by the casting functions as above since rif:iri is not a datatype with a well-defined value space. To this end, since conversions from IRIs (resources) to strings are a needed feature for instance for conversions between RDF formats (see example below), we add a built-in predicate which supports such conversions.xs:date

This predicate could be usable for instance to map telephone numbers between an RDF Format for vCard ( http://www.w3.org/TR/vcard-rdf ) and FOAF ( http://xmlns.com/foaf/0.1/ ). vCard stores telephone numbers as string literals, whereas FOAF uses resources, i.e., URIs with the tel: URI-scheme. So, a mapping from FOAF to vCard would need to convert the tel: URI to a string and then cut off the first four characters ("tel:"). Such a mapping expressed in RIF could involve e.g. a rule as follows: ... Prefix( VCard http://www.w3.org/TR/vcard-rdf# ) Prefix( foaf http://xmlns.com/foaf/0.1/ ) ... Forall?X?foafTelIri?foafTelString ( ?X[ VCard:tel -> External( func:substring(?foafTelString 4 ) ]:- And (?X[ foaf:phone ->?foafTelIri ] External( pred:iri-to-string(?foafTelIri?foafTelString ) ) ) 3.4 Numeric Functions and Predicates The following functions and predicates are adapted from the respective numeric functions and operators in [ XPath-Functions ]. 3.4.1 Numeric Functions 3.4.1.1 func:numeric-add (adapted from op:numeric-add )3.3.6 xs:dateTime

The following numeric built-in functions func:numeric-subtract , func:numeric-multiply , func:numeric-divide , func:numeric-integer-divide , and func:numeric-mod are defined accordingly with respect to their corresponding operators in [ XPath-Functions ] and we will only add further explanations where needed. 3.4.1.2 func:numeric-subtract (adapted from op:numeric-subtract )3.3.7 xs:dayTimeDuration

3.3.8 xs:yearMonthDuration

3.3.9 xs:string

Note: Since RIF does not prescribe the behavior if the second argument is zero. 3.4.2 Numeric Predicates 3.4.2.1 pred:numeric-equal (adapted from op:numeric-equal ) Schema : (?arg 1 ?arg 2 ; pred:numeric-equal(?argimplementations MAY choose to interpret xs:string and its subtypes as subtypes of rdf:text following Section 3.1 of [RDF-TEXT], in such implementations this cast function also serves for conversions to rdf:text.

3.3.10 rdf:XMLLiteral

The following numeric built-in predicates pred:numeric-less-than3.3.11 pred:iri-string

Conversions from rif:iri to xs:string and pred:numeric-greater-than arevice versa cannot be defined acordinglyby the casting functions as above since rif:iri is not a datatype with respecta well-defined value space.

To their corresponding operators in [ XPath-Functions ]. Thethis end, since conversions from IRIs (resources) to strings are a needed feature for instance for conversions between RDF formats (see example below), we introduce a built-in predicate pred:numeric-not-equal has the samewhich supports such conversions.

3.3.12 pred:hasDatatype

Extractions of the Datatype from a constant cannot be defined by a function (like for instance in SPARQL's datatype function) since the value spaces of datatypes may overlap.

To this end, we introduce a built-in predicate which supports extraction of the datatypes for a constant at hand.

  • Schema:

    (?arg1?arg2; pred:hasDatatype (?arg1,?arg2 ) )

  • Intended domains:

    None of the arguments is restricted to a specific domain.

  • Mapping:

    Iexternal(?arg1?arg2; pred:hasDatatype (?arg1?arg2 ) )(const1 iri1) = t if and only if in the current interpretation iri1 = I( "DatatypeIRI"^^rif:iri ) where DatatypeIRI is the IRI identifier of a datatype d and const1 is in the value space of d.

Editor's Note: It is still under discussion in the WG whether this predicate should restrict the domain of the second argument rather to strings that represent valid IRIs than just being true for any constants that have the same interpretation as the particular rif:iri representing the datatype.

This predicate can be usable for extracting the datatype from a constant but due to the overlap of the calue spaces of datatypes, such extraction is not necessarily unique; for example, the following is entailed in any RIF ruleset:

  And ( External( pred:hasDatatype( "1.0"^^xs:decimal xs:decimal ) )
        External( pred:hasDatatype( "1.0"^^xs:decimal xs:integer ) )
        External( pred:hasDatatype( "1.0"^^xs:decimal xs:double  ) ) )

Editor's Note: Note that this example shows that pred:hasDatatype is not adequate for emulating SPARQL's datatype function http://www.w3.org/TR/rdf-sparql-query/#func-datatype, cf. the mail thread starting at http://lists.w3.org/Archives/Public/public-rif-wg/2008Nov/0067.html

The following example shows that also whether or not a RIF implementation that treats xs:string as a subtype of rdf:text may affect the entailments for pred:hasDatatype:

  Forall?X (
   ?P [ ex:nameType ->?D ]:-  
          And (?P[ foaf:name ->?N ]
                External( pred:hasDatatype(?N?D ) ) )
  ex:alice [foaf:name -> "Alice"]

In a RIF implementation that treats xs:string as a subtype of rdf:text, following Section 3.1 of [RDF-TEXT], this ruleset would entail both ex:alice [ex:nameType -> rdf:text] and ex:alice [ex:nameType -> xs:string].

Editor's Note: Whether or not we allow the treatment of xs:string as a subtype of rdf:text in RIF implementations is still under discussion, cf. the mail thread starting at http://lists.w3.org/Archives/Public/public-rif-wg/2008Nov/0067.html.

3.4 Numeric Functions and Predicates

The following functions and predicates are adapted from the respective numeric functions and operators in [XPath-Functions].

3.4.1 Numeric Functions

3.4.1.1 func:numeric-add (adapted from op:numeric-add)

  • Schema:

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

  • Intended domains:

    The value spaces of xs:integer, xs:double, or xs:decimal for both arguments.

  • Mapping:

    When both s1 and s2 belong to their intended domains, External(func:numeric-add(s1 s2)) evaluates to the result of op:numeric-add(s1, s2) as defined in [XPath-Functions].

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

The following numeric built-in functions func:numeric-subtract, func:numeric-multiply, func:numeric-divide, func:numeric-integer-divide, and func:numeric-mod are defined accordingly with respect to their corresponding operators in [XPath-Functions] and we will only add further explanations where needed.

3.4.1.2 func:numeric-subtract (adapted from op:numeric-subtract)

  • Schema:

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

3.4.1.3 func:numeric-multiply (adapted from op:numeric-multiply)

  • Schema:

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

3.4.1.4 func:numeric-divide (adapted from op:numeric-divide)

  • Schema:

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

  • Intended domains:

    The value spaces of xs:integer, xs:double, or xs:decimal for the first argument and xs:integer, xs:double, or xs:decimal without zero for the second argument.

  • Mapping:

    This function backs up the "div" operator and returns the arithmetic quotient of its operands

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another, which here particularly means that RIF does not prescribe the behavior on division by zero.

3.4.1.5 func:numeric-integer-divide (adapted from op:numeric-integer-divide)

  • Schema:

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

  • Intended domains:

    The value spaces of xs:integer, xs:double, or xs:decimal for the first argument and xs:integer, xs:double, or xs:decimal without zero for the second argument.

  • Mapping:

    This function backs up the "idiv" operator and performs an integer division: that is, it divides the first argument by the second, and returns the integer obtained by truncating the fractional part of the result.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another, which here particularly means that RIF does not prescribe the behavior on division by zero.

3.4.1.6 func:numeric-mod (adapted from op:numeric-mod)

  • Schema:

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

  • Intended domains:

    The value spaces of xs:integer, xs:double, or xs:decimal for the first argument and xs:integer, xs:double, or xs:decimal without zero for the second argument.

  • Mapping:

    Backs up the "mod" operator.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another, which here particularly means that RIF does not prescribe the behavior if the second argument is zero.

3.4.2 Numeric Predicates

3.4.2.1 pred:numeric-equal (adapted from op:numeric-equal)

  • Schema:

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

  • Intended domains:

    The value spaces of xs:integer, xs:double, or xs:decimal for both arguments.

  • Mapping:

    When both s1 and s2 belong to their intended domains, External(pred:numeric-equal(s1 s2)) is t if and only if op:numeric-equal(s1, s2) returns true, as defined in [XPath-Functions].

    If an argument value is outside of the intended domain, the truth value of the function is left unspecified and can vary from one semantic structure to another.

The following numeric built-in predicates pred:numeric-less-than and pred:numeric-greater-than are defined accordingly with respect to their corresponding operators in [XPath-Functions].

3.4.2.2 pred:numeric-less-than (adapted from op:numeric-less-than)

  • Schema:

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

3.4.2.3 pred:numeric-greater-than (adapted from op:numeric-greater-than)

  • Schema:

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

3.4.2.4 pred:numeric-not-equal

  • Schema:

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

The predicate pred:numeric-not-equal has the same intended domains as pred:numeric-equal and is true whenever pred:numeric-equal is false.

3.4.2.5 pred:numeric-less-than-or-equal

  • Schema:

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

The predicate pred:numeric-less-than-or-equal has the same intended domains as pred:numeric-equal and is true whenever pred:numeric-equal is true or pred:numeric-less-than is true.

3.4.2.6 pred:numeric-greater-than-or-equal

  • Schema:

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

The predicate pred:numeric-greater-than-or-equal has the same intended domains as pred:numeric-equal and is true whenever pred:numeric-equal is true or pred:numeric-greater-than is true.

3.5 Functions and Predicates on Strings

The following functions and predicates are adapted from the respective functions and operators on strings in [XPath-Functions].

Editor's Note: The following treatment of built-ins which may have multiple arities is a strawman proposal currently under discussion in the working group.

In the following, we encounter several versions of some built-ins with varying arity, since XPath and XQuery allow overloading, i.e. the same function or operator name occurring with different arities. We 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( strExternal( func:concat2( str1, str2) ) and External( func:concat3( str1 str2 str3 ) ) we allow the equivalent forms External( func:concat( str1, str2) ) and External( func:concat( str1 str2 str3 ) ). Note that this is really purely syntactic sugar, and does not mean that for external predicates and functions we lift the restriction made in BLD that each function and predicate has a unique assigned arity. Those schemata for which we allow this syntactic sugar, appear in the same box.

3.5.1 Functions on Strings

3.5.1.1 func:compare (adapted from fn:compare)

  • Schema:

    (?comparand1?comparand2; func:compare1(?comparand1?comparand2) )

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Iexternal( (?comparand1?comparand2; func:compare1(?comparand1?comparand2) )(s1 s2) = res such that res = -1, 0, or 1 (from the value space of xs:integer), 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.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

The following schemata are defined analogously with respect to their corresponding operators as defined in [XPath-Functions] and we only give informal descriptions of the respective mappings Iexternal.

3.5.1.2 func:concat (adapted from fn:concat)

  • Schema:

    (?arg1; func:concat1(?arg1 ) )

    (?arg1?arg2; func:concat2(?arg1?arg2 ) )

    ...

    (?arg1 ?arg2 ...?argn; func:concatn(?arg1?arg2 ...?argn ) )

  • Intended domains:

    Following the definition of fn:concat this function accepts xs:anyAtomicType arguments and casts them to xs:string. Thus, the intended domain for all arguments is the union of all value spaces castable to String xs:string as defined in Section Cast Functions and Conversion Predicates for Datatypes and rif:iri above.

  • Mapping:

    Returns the xs:string that is the concatenation of the values of its arguments after conversion.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.3 func:string-join (adapted from fn:string-join)

  • Schema:

    (?arg1?arg2; func:string-join2(?arg1?arg2 ) )

    (?arg1?arg2?arg3; func:string-join3(?arg1?arg2?arg3 ) )

    ...

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Returns a xs:string created by concatenating the arguments 1 to (n-1) using the nth argument as a separator.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.4 func:substring (adapted from fn:substring)

  • Schema:

    (?sourceString?startingLoc; func:substring1(?sourceString?startingLoc) )

    (?sourceString?startingLoc?length; func:substring2(?sourceString?startingLoc?length) )

  • Intended domains:

    The value space of xs:string for ?sourceString and the union of the value spaces of xs:integer, xs:long, or xs:decimal for the remaining two arguments.

  • Mapping:

    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.

    If an argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.5 func:string-length (adapted from fn:string-length)

  • Schema:

    ( func:string-length1() )

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

  • Intended domains:

    The value space of xs:string for ?arg.

  • Mapping:

    Returns an xs:integer equal to the length in characters of the argument if it is a xs:string, returns 0 when called without an argument.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.6 func:upper-case (adapted from fn:upper-case)

  • Schema:

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

  • Intended domain:

    The value space of xs:string for ?arg.

  • Mapping:

    Returns the value of?arg after translating every character to its upper-case correspondent as defined in the appropriate case mappings section in the Unicode standard.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.7 func:lower-case (adapted from fn:lower-case)

  • Schema:

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

  • Intended domain:

    The value space of xs:string for ?arg.

  • Mapping:

    Returns the value of?arg after translating every character to its lower-case correspondent as defined in the appropriate case mappings section in the Unicode standard.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.8 func:encode-for-uri (adapted from fn:encode-for-uri)

  • Schema:

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

  • Intended domains:

    The value space of xs:string for ?arg.

  • Mapping:

    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.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.9 func:iri-to-uri (adapted from fn:iri-to-uri)

  • Schema:

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

  • Intended domains:

    The value space of xs:string for ?iri.

  • Mapping:

    This function converts an xs:string containing an IRI into a URI according to the rules spelled out in Section 3.1 of RFC 3987. It is idempotent but not invertible.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.10 func:escape-html-uri (adapted from fn:escape-html-uri)

  • Schema:

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

  • Intended domains:

    The value space of xs:string for ?uri.

  • Mapping:

    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.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.11 func:substring-before (adapted from fn:substring-before)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Returns the substring of the value of?arg1 that precedes in the value of?arg1 the first occurrence of a sequence of collation units that provides a minimal match to the collation units of?arg2 according to the collation that is used.

    If any argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.12 func:substring-after (adapted from fn:substring-after)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Returns the substring of the value of?arg1 that follows in the value of?arg1 the first occurrence of a sequence of collation units that provides a minimal match to the collation units of?arg2 according to the collation that is used.

    If any argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.13 func:replace (adapted from fn:replace)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    The function returns the xs:string that is obtained by replacing each non-overlapping substring of?input that matches the given?pattern with an occurrence of the?replacement string.

    If any argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2 Predicates on Strings

3.5.2.1 pred:contains (adapted from fn:contains)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    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.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.


3.5.2.2 pred:starts-with (adapted from fn:starts-with)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Returns true or false indicating whether or not the value of?arg1 starts with a sequence of collation units that provides a minimal match to the collation units of?arg2 according to the collation that is used.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.


3.5.2.3 pred:ends-with (adapted from fn:ends-with)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    Returns true or false indicating whether or not the value of?arg1 ends with a sequence of collation units that provides a minimal match to the collation units of?arg2 according to the collation that is used.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2.4 pred:matches (adapted from fn:matches)

  • Schema:

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

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

  • Intended domains:

    The value space of xs:string for all arguments.

  • Mapping:

    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.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

Following the convention of having separate equality, inequality, less-than, greater-than, less-than-or-equal, greater-than-or-equal predicates for other datatypes, RIF defines such predicates as syntactic sugar over func:compare also for xs:string in the following.

Editor's Note: The need of separate equality, inequality, less-than, greater-than, less-than-or-equal, greater-than-or-equal predicates for strings is still under discussion, cf. ISSUE-67.

3.5.2.5 pred:string-equal

  • Schema:

    (?comparand1 , str?comparand2 ) ) and External( func:concat3( str; pred:string-equal(?comparand1 str?comparand2 str 3) )

  • we allowIntended domains:

    The equivalent forms External( func:concat( strvalue space of xs:string for both arguments.

  • Mapping:

    When both s1 , str 2 ) )and External( func:concat( strs2 belong to their intended domains, Itruth Iexternal( (?comparand1 str?comparand2; pred:string-equal(?comparand1?comparand2 str 3) )(s1 s2) . Note that this is really purely syntactic sugar,= t if and does not mean that foronly if Iexternal predicates and functions we lift the restriction made in BLD that each function and predicate has a unique assigned arity. Those schemata for which we allow this syntactic sugar, appear in the same box. 3.5.1 Functions on Strings 3.5.1.1 func:compare (adapted from fn:compare ) Schema :( (?comparand1?comparand2; func:compare1(?comparandpred:compare(?comparand1?comparand2) )(s1 s2) = 0.

    If an argument value is outside of the intended domain, the value of the truth value of the predicate is left unspecified and can vary from one semantic structure to another.

3.5.2.6 pred:string-less-than

  • Schema:

    (?comparand1 $comparand?comparand2 $collation; func:compare2(?comparand; pred:string-less-than(?comparand1?comparand2 ?collation)) )

  • Intended domains:

    The value space of xs:string for allboth arguments.

  • Mapping:

    When both s1 and s2 belong to their intended domains, Itruth Iexternal( (?comparand1?comparand2; pred:string-less-than(?comparand1?comparand2) )(s1 s2) = t if and only if Iexternal( (?comparand1?comparand2; func:compare1(?comparandpred:compare(?comparand1?comparand2) )(s1 s2) = res such that res = -1 , 0 , or 0 (from the value space of xs:integer ), depending on whether the value of the s 1 is respectively less than, equal to, or greater than the value of s 2 , according to the rules of the collation that is used.-1.

    If an argument value is outside of the intended domain, the value of the functiontruth value of the predicate is left unspecified and can vary from one semantic structure to another.

Editor's Note: The working group is currently discussing, whether in addition to adopting the fn:compare function from [ XPath-Functions ], own predicates pred:string-equal , pred:string-less-than ,3.5.2.7 pred:string-greater-than

  • , pred:string-not-equal , pred:string-less-than-or-equal , pred:string-greater-than-or-equal not defined in [ XPath-Functions ] shall be introduced, following the convention of having such predicates for other datatypes. The following schemata are defined analogously with respect to their corresponding operators as defined in [ XPath-Functions ] and we only give informal descriptions of the respective mappings I external . 3.5.1.2 func:concat (adapted from fn:concat )Schema:

    (?arg 1 ; func:concat1(?arg 1 ) ) (?arg 1 ?arg 2 ; func:concat2(?arg 1 ?arg 2 ) ) ... (?arg(?comparand1 ?arg?comparand2 ...?arg n; func:concat n (?argpred:string-greater-than(?comparand1 ?arg?comparand2 ...?arg n) )

  • Intended domains:

    FollowingThe definitionvalue space of fn:concat this function accepts xs:anyAtomicType arguments and casts them toxs:string . Thus, the intended domainfor all arguments is the union of all value spaces castable to String xs:string as defined in Section Cast Functionsboth arguments.

  • Mapping:

    When both s1 and Conversion Predicates for Datatypess2 belong to their intended domains, Itruth Iexternal( (?comparand1?comparand2; pred:string-greater-than(?comparand1?comparand2) )(s1 s2) = t if and rif:iri above. Mapping: Returns the xs:string that is the concatenation of the values of its arguments after conversion.only if Iexternal( (?comparand1?comparand2; pred:compare(?comparand1?comparand2) )(s1 s2) = 1.

    If an argument value is outside of the intended domain, the value of the functiontruth value of the predicate is left unspecified and can vary from one semantic structure to another.

3.5.1.3 func:string-join (adapted from fn:string-join )The following built-in predicates pred:string-not-equal, pred:string-less-than-or-equal and pred:string-greater-than-or-equal are defined accordingly.

3.5.2.8 pred:string-not-equal

  • Schema:

    (?arg(?comparand1 ?arg?comparand2; func:string-join2(?argpred:string-not-equal(?comparand1 ?arg?comparand2) )

(?argThe predicate pred:string-not-equal has the same intended domains as pred:string-equal and is true whenever pred:string-equal is false.

3.5.2.9 pred:string-less-than-or-equal

  • Schema:

    (?comparand1 ?arg?comparand2 ?arg 3; func:string-join3(?argpred:string-less-than-or-equal(?comparand1 ?arg?comparand2 ?arg 3) )

... (?argThe predicate pred:string-less-than-or-equal has the same intended domains as pred:string-equal and is true whenever pred:string-equal is true or pred:string-less-than is true.

3.5.2.10 pred:string-greater-than-or-equal

  • Schema:

    (?comparand1 ?arg?comparand2 ...?arg n; func:string-join n (?argpred:string-greater-than-or-equal(?comparand1 ?arg?comparand2 ...?arg n) )

The predicate pred:string-greater-than-or-equal has the same intended domains :as pred:string-equal and is true whenever pred:string-equal is true or pred:string-greater-than is true.

3.6 Functions and Predicates on Dates, Times, and Durations

If not stated otherwise, in the value space of xs:stringfollowing we define schemas for all arguments. Mapping: Returns a xs:string created by concatenatingfunctions and operators defined on the arguments 1date, time and duration datatypes in [XPath-Functions].

As defined in Section 3.3.2 Dates and Times, xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth, xs:gDay values, referred to ( n -1) usingcollectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, second and timezone. The n th argument as a separator. If an argumentvalue is outsideof the intended domain,first five components are xs:integers. The value of the functionsecond component is left unspecifiedan xs:decimal and can vary from one semantic structure to another. 3.5.1.4 func:substring (adapted from fn:substring ) Schema : (?sourceString?startingLoc; func:substring1(?sourceString?startingLoc) ) (?sourceString?startingLoc?length; func:substring2(?sourceString?startingLoc?length) ) Intended domains :the value space of xs:string for ?sourceString and the unionof the value spaces of xs:integer , xs:long , or xs:decimaltimezone component is an xs:dayTimeDuration. For all the remaining two arguments. Mapping: Returns the portion of the value of?sourceString beginning at the position indicated bydate/time datatypes, the value of?startingLoctimezone property is optional and continuing formay or may not be present. Depending on the numberdatatype, some of characters indicated bythe value of?length. The characters returned do not extend beyond?sourceString. If?startingLoc is zeroremaining six properties must be present and some must be absent. Absent, or negative, only those characters in positions greater than zeromissing, properties are returned. If an argument value is outside of its intended domain,represented by the empty sequence. This value of the functionis left unspecified and can vary from one semantic structurereferred to another. 3.5.1.5 func:string-length (adapted from fn:string-length ) Schema : ( func:string-length1() ) (?arg; func:string-length2(?arg ) ) Intended domains :as the local value space of xs:string for ?arg. Mapping: Returns an xs:integer equal to the lengthin characters of the argument if it is a xs:string . Ifthat the argumentvalue is outside of its intended domain, the value ofin the function is left unspecified and can vary from one semantic structuregiven timezone. Before comparing or subtracting xs:dateTime values, this local value must be translated or normalized to another. 3.5.1.6 func:upper-caseUTC.

3.6.1 Functions on Dates, Times, and Durations

3.6.1.1 func:year-from-dateTime (adapted from fn:upper-casefn:year-from-dateTime)

  • Schema:

    (?arg; func:upper-case(?argfunc:year-from-dateTime(?arg ) )

  • Intended domaindomains:

    The value space of xs:string for ?arg.xs:dateTime for?arg.

  • Mapping:

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

    such that res is the value of?arg after translating every character to its upper-case correspondentresult of fn:year-from-dateTime(s) as defined in the appropriate case mappings section in the Unicode standard.[XPath-Functions].

    If thean argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.7 func:lower-caseNote that we 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". The following schemata are defined analogously with respect to their corresponding operators as defined in [XPath-Functions] and we only give informal descriptions of the respective mappings Iexternal.

3.6.1.2 func:month-from-dateTime (adapted from fn:lower-casefn:month-from-dateTime)

  • Schema:

    (?arg; func:lower-case(?argfunc:month-from-dateTime(?arg ) )

  • Intended domaindomains:

    The value space of xs:string for ?arg.xs:dateTime for?arg.

  • Mapping:

    Returns an xs:integer between 1 and 12, both inclusive, representing the value of?arg after translating every character to its lower-case correspondent as defined in the appropriate case mappings sectionmonth component in the Unicode standard.localized value of?arg.

    If thean argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.8 func:encode-for-uri3.6.1.3 func:day-from-dateTime (adapted from fn:encode-for-urifn:day-from-dateTime)

  • Schema:

    (?arg; func:encode-for-uri(?argfunc:day-from-dateTime(?arg ) )

  • Intended domains:

    The value space of xs:string for ?arg.xs:dateTime for?arg.

  • Mapping:

    This function encodes reserved characters inReturns an xs:string that is intended to be usedxs:integer between 1 and 31, both inclusive, representing the day component in the path segment of a URI. It is invertible but not idempotent.localized value of?arg.

    If thean argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.9 func:iri-to-uri3.6.1.4 func:hours-from-dateTime (adapted from fn:iri-to-urifn:hours-from-dateTime)

  • Schema:

    (?iri; func:iri-to-uri (?iri(?arg; func:hours-from-dateTime(?arg ) )

  • Intended domains:

    The value space of xs:string for ?iri.xs:dateTime for?arg.

  • Mapping:

    This function converts an xs:string containingReturns an IRI into a URI according toxs:integer between 0 and 23, both inclusive, representing the rules spelled outhours component in Section 3.1 of RFC 3987 . It is idempotent but not invertible. Ifthe localized value of?arg.

    If an argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.10 func:escape-html-uri3.6.1.5 func:minutes-from-dateTime (adapted from fn:escape-html-urifn:minutes-from-dateTime)

  • Schema:

    (?uri;func:escape-html-uri(?uri(?arg; func:minutes-from-dateTime(?arg ) )

  • Intended domains:

    The value space of xs:string for ?uri.xs:dateTime for?arg.

  • Mapping:

    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 byReturns an escape sequence, which is formed by encoding the character as a sequence of octets in UTF-8,xs:integer between 0 and then59, both inclusive, representing each of these octets in the form%HH, where HH is the hexadecimal representation ofthe octet. This function must always generate hexadecimal values usingminutes component in the upper-case letters A-F.localized value of?arg.

    If thean argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.11 func:substring-before3.6.1.6 func:seconds-from-dateTime (adapted from fn:substring-beforefn:seconds-from-dateTime)

  • Schema:

    (?arg 1 ?arg 2 ; func:substring-before1(?arg 1 ?arg 2 ) ) (?arg 1 ?arg 2 ?collation; func:substring-before2(?arg 1 ?arg 2 ?collation(?arg; func:seconds-from-dateTime(?arg ) )

  • Intended domains:

    The value space of xs:string for all arguments.xs:dateTime for?arg.

  • Mapping:

    Returns the substring of the value of?arg1 that precedes in thean xs:decimal value of?arg1 the first occurrence of a sequence of collation units that provides a minimal matchgreater than or equal to zero and less than 60, representing the collation units of?arg2 according toseconds and fractional seconds in the collation that is used.localized value of?arg.

    If anyan argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.12 func:substring-after3.6.1.7 func:year-from-date (adapted from fn:substring-afterfn:year-from-date)

  • Schema:

    (?arg 1 ?arg 2 ; func:substring-after1(?arg 1 ?arg 2 ) ) (?arg 1 ?arg 2 ?collation; func:substring-after2(?arg 1 ?arg 2 ?collation(?arg; func:year-from-date(?arg ) )

  • Intended domains:

    The value space of xs:string for all arguments.xs:date for?arg.

  • Mapping:

    Returns an xs:integer representing the substring of the value of?arg1 that followsyear in the localized value of?arg1 the first occurrence of a sequence of collation units that provides a minimal match to the collation units of?arg2 according toof?arg. The collation that is used.value may be negative.

    If anyan argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.1.13 func:replace3.6.1.8 func:month-from-date (adapted from fn:replacefn:month-from-date)

  • Schema:

    (?input?pattern?replacement; func:replace1(?input?pattern?replacement ) ) (?input?pattern?replacement?flags; func:replace2(?input?pattern?replacement?flags(?arg; func:month-from-date(?arg ) )

  • Intended domains:

    The value space of xs:string for all arguments.xs:date for?arg.

  • Mapping:

    The functionReturns an xs:integer between 1 and 12, both inclusive, representing the xs:string that is obtained by replacing each non-overlapping substring of?input that matchesmonth component in the given?pattern with an occurrence of the?replacement string.localized value of?arg.

    If anyan argument value is outside of itsthe intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2 Predicates on Strings 3.5.2.1 pred:contains3.6.1.9 func:day-from-date (adapted from fn:containsfn:day-from-date)

  • Schema:

    (?arg 1 ?arg 2 ; pred:contains1(?arg 1 ?arg 2 ) ) (?arg 1 ?arg 2 ?collation; pred:contains2(?arg 1 ?arg 2 ?collation(?arg; func:day-from-date(?arg ) )

  • Intended domains:

    The value space of xs:string for all arguments.xs:date for?arg.

  • Mapping:

    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 toan xs:integer between 1 and 31, both inclusive, representing the collation unitsday component in the value of?arg2, according to the collation that is used. "Minimal match" is defined in Unicode Collation Algorithm .localized value of?arg.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2.2 pred:starts-with3.6.1.10 func:hours-from-time (adapted from fn:starts-withfn:hours-from-time)

  • Schema:

    (?arg 1 ?arg 2 ; pred:starts-with1(?arg 1 ?arg 2(?arg; func:hours-from-time(?arg ) )

  • (?arg 1 ?arg 2 ?collation; pred:starts-with2(?arg 1 ?arg 2 ?collation)Intended domains:

    The value space of xs:string for all arguments.xs:time for?arg.

  • Mapping:

    Returns true or false indicating whether or not the value of?arg1 starts with a sequence of collation units that provides a minimal match toan xs:integer between 0 and 23, both inclusive, representing the collation units of?arg2 according tohours component in the collation that is used.localized value of?arg.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2.3 pred:ends-with3.6.1.11 func:minutes-from-time (adapted from fn:ends-withfn:minutes-from-time)

  • Schema:

    (?arg 1 ?arg 2 ; fn:ends-with1(?arg 1 ?arg 2 )(?arg; func:minutes-from-time(?arg ) (?arg 1 ?arg 2 ?collation; fn:ends-with2(?arg 1 ?arg 2 ?collation))

  • Intended domains:

    The value space of xs:string for all arguments.xs:time for?arg.

  • Mapping:

    Returns true or false indicating whether or not the value of?arg1 ends with a sequence of collation units that provides a minimal match toan xs:integer between 0 and 59, both inclusive, representing the collation units of?arg2 according tominutes component in the collation that is used.localized value of?arg.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.5.2.4 pred:matches3.6.1.12 func:seconds-from-time (adapted from fn:matchesfn:seconds-from-time)

  • Schema:

    (?input?pattern; pred:matches1(?input?pattern) ) (?input?pattern?flags; pred:matches2(?input?pattern?flags(?arg; func:seconds-from-time(?arg ) )

  • Intended domains:

    The value space of xs:string for all arguments.xs:time for?arg.

  • Mapping:

    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 callingan xs:decimal value greater than or equal to zero and less than 60, representing the second version withseconds and fractional seconds in the flags argument set to a zero-length string.localized value of?arg.

    If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.6 Functions and Predicates on Dates, Times, and Durations If not stated otherwise, in3.6.1.13 func:years-from-duration (adapted from fn:years-from-duration)

  • Schema:

    (?arg; func:years-from-duration(?arg ) )

  • Intended domains:

    The following we define schemas for functions and operators defined onunion of the date and timevalue spaces of datatypes in [ XPath-Functions ]. As defined in Section 3.3.2 Dates and Times , xs:dateTime, xs:date, xs:time, xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth, xs:gDay values, referredcastable to xs:yearMonthDuration according to collectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, second and timezone.the valuetable in Section 17.1 of [XPath-Functions].

  • Mapping:

    Returns an xs:integer representing the first five components are xs:integers.years component in the value ofof?arg. The second componentresult is obtained by casting?arg to an xs:decimalxs:yearMonthDuration and then computing the years component.

    If the argument value is outside of the timezone component is an xs:dayTimeDuration. For allintended domain, the date/time datatypes,value of the timezone propertyfunction is optionalleft unspecified and may or may not be present. Depending oncan vary from one semantic structure to another.

3.6.1.14 func:months-from-duration (adapted from fn:months-from-duration)

  • Schema:

    (?arg; func:months-from-duration(?arg ) )

  • Intended domains:

    The datatype, someunion of the remaining six properties must be present and some must be absent. Absent, or missing, properties are represented by the empty sequence. Thisvalue is referredspaces of datatypes castable to xs:yearMonthDuration according to asthe local valuetable in Section 17.1 of [XPath-Functions].

  • Mapping:

    Returns an xs:integer representing the months component in thatthe value of?arg. The result is inobtained by casting?arg to an xs:yearMonthDuration and then computing the months component.

    If the argument value is outside of the intended domain, the given timezone. Before comparing or subtracting xs:dateTime values, this localvalue must be translated or normalized to UTC. 3.6.1 Functions on Dates, Times,of the function is left unspecified and Durations 3.6.1.1 func:year-from-dateTimecan vary from one semantic structure to another.

3.6.1.15 func:days-from-duration (adapted from fn:year-from-dateTimefn:days-from-duration)

  • Schema:

    (?arg; func:year-from-dateTime(?argfunc:days-from-duration(?arg ) )

  • Intended domains:

    The union of the value spacespaces of xs:dateTime for?arg. Mapping: I external (?arg; func:year-from-dateTime(?arg ) )(s) = res such that res isdatatypes castable to xs:dayTimeDuration according to the resulttable in Section 17.1 of fn:year-from-dateTime (s) as defined[XPath-Functions].

  • Mapping:

    Returns an xs:integer representing the days component in [ XPath-Functions ]. Ifthe value of?arg. The result is obtained by casting?arg to an xs:dayTimeDuration and then computing the days component.

    If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

Note that we 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". The following schemata are defined analogously with respect to their corresponding operators as defined in [ XPath-Functions ] and we only give informal descriptions of the respective mappings I external . 3.6.1.2 func:month-from-dateTime3.6.1.16 func:hours-from-duration (adapted from fn:month-from-dateTimefn:hours-from-duration)

  • Schema:

    (?arg; func:month-from-dateTime(?argfunc:hours-from-duration(?arg ) )

  • Intended domains:

    The union of the value spacespaces of xs:dateTime for?arg.datatypes castable to xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].

  • Mapping:

    Returns an xs:integer between 1 and 12, both inclusive,representing the monthhours component in the localizedvalue of?arg. IfThe result is obtained by casting?arg to an xs:dayTimeDuration and then computing the hours component.

    If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.6.1.3 func:day-from-dateTime3.6.1.17 func:minutes-from-duration (adapted from fn:day-from-dateTimefn:minutes-from-duration)

  • Schema:

    (?arg; func:day-from-dateTime(?argfunc:minutes-from-duration(?arg ) )

  • Intended domains:

    The union of the value spacespaces of xs:dateTime for?arg.datatypes castable to xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].

  • Mapping:

    Returns an xs:integer between 1 and 31, both inclusive,xs:integer representing the dayminutes component in the localizedvalue of?arg. IfThe result is obtained by casting?arg to an xs:dayTimeDuration and then computing the minutes component.

    If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.6.1.4 func:hours-from-dateTime3.6.1.18 func:seconds-from-duration (adapted from fn:hours-from-dateTimefn:seconds-from-duration)

  • Schema:

    (?arg; func:hours-from-dateTime(?argfunc:seconds-from-duration(?arg ) )

  • Intended domains:

    The union of the value spacespaces of xs:dateTime for?arg.datatypes castable to xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].

  • Mapping:

    Returns an xs:integer between 0 and 23, both inclusive,xs:decimal representing the hoursseconds component in the localizedvalue of?arg. IfThe result is obtained by casting?arg to an xs:dayTimeDuration and then computing the seconds component.

    If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.6.1.5 func:minutes-from-dateTime3.6.1.19 func:timezone-from-dateTime (adapted from fn:minutes-from-dateTimefn:timezone-from-dateTime)

  • Schema:

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

  • Intended domains:

    The value space of xs:dateTime for?arg..

  • Mapping:

    Returns an xs:integer between 0 and 59, both inclusive, representingthe minutestimezone component inof?arg if any. If $arg has a timezone component, then the localizedresult is an xs:dayTimeDuration that indicates deviation from UTC; its value of?arg.may range from +14:00 to -14:00 hours, both inclusive.

    If anthe argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.6.1.6 func:seconds-from-dateTimeThe following two functions are defined analogously for intended domains xs:date and xs:time

3.6.1.20 func:timezone-from-date (adapted from fn:seconds-from-dateTimefn:timezone-from-date)

  • Schema:

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

3.6.1.21 func:timezone-from-time (adapted from fn:timezone-from-time)

  • Schema:

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

3.6.1.22 func:subtract-dateTimes (adapted from op:subtract-dateTimes)

  • Schema:

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

Subtracts two xs:dateTimes. Returns an xs:xs:dayTimeDuration.

3.6.1.23 func:subtract-dates (adapted from op:subtract-dates)

  • Schema:

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

Subtracts two xs:dates. Returns an xs:xs:dayTimeDuration.

3.6.1.24 func:subtract-times (adapted from op:subtract-times)

  • Schema:

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

Subtracts two xs:times. Returns an xs:xs:dayTimeDuration.

3.6.1.25 func:add-yearMonthDurations (adapted from op:add-yearMonthDurations)

  • Schema:

    (?arg; func:seconds-from-dateTime(?arg(?arg1?arg2; func:add-yearMonthDurations(?arg1?arg2 ) )

Intended domains : The value space of xs:dateTime for?arg. Mapping:Adds two xs:yearMonthDurations. Returns an xs:decimal value greater than or equal to zero and less than 60, representing the seconds and fractional seconds in the localized value of?arg. If an argument value is outside of the intended domain, the value of the function is left unspecified and can varyxs:yearMonthDuration.

3.6.1.26 func:subtract-yearMonthDurations (adapted from op:subtract-yearMonthDurations)

  • Schema:

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

Subtracts one semantic structure toxs:yearMonthDuration from another. 3.6.1.7 func:year-from-dateReturns an xs:yearMonthDuration.

3.6.1.27 func:multiply-yearMonthDuration (adapted from fn:year-from-dateop:multiply-yearMonthDuration)

  • Schema:

    (?arg; func:year-from-date(?arg(?arg1?arg2; func:multiply-yearMonthDuration(?arg1?arg2 ) )

Intended domains : The value space of xs:date for?arg. Mapping: ReturnsMultiplies an xs:integer representing the year in the localized value of?arg. The value may be negative. Ifxs:yearMonthDuration by an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.8 func:month-from-datexs:double. Returns an xs:yearMonthDuration.

3.6.1.28 func:divide-yearMonthDuration (adapted from fn:month-from-dateop:divide-yearMonthDuration)

  • Schema:

    (?arg; func:month-from-date(?arg(?arg1?arg2; func:divide-yearMonthDuration(?arg1?arg2 ) )

Intended domains : The value space of xs:date for?arg. Mapping: ReturnsDivides an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of?arg. Ifxs:yearMonthDuration by an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.9 func:day-from-datexs:double. Returns an xs:yearMonthDuration.

3.6.1.29 func:divide-by-yearMonthDuration (adapted from fn:day-from-dateop:divide-yearMonthDuration-by-yearMonthDuration)

  • Schema:

    (?arg; func:day-from-date(?arg(?arg1?arg2; func:divide-yearMonthDuration-by-yearMonthDuration(?arg1?arg2 ) )

Intended domains : The value space of xs:date for?arg. Mapping: ReturnsDivides an xs:integer between 1 and 31, both inclusive, representing the day component in the localized value of?arg. Ifxs:yearMonthDuration by an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.10 func:hours-from-timexs:yearMonthDuration. Returns an xs:decimal.

3.6.1.30 func:add-dayTimeDurations (adapted from fn:hours-from-timeop:add-dayTimeDurations)

  • Schema:

    (?arg; func:hours-from-time(?arg(?arg1?arg2; func:add-dayTimeDurations(?arg1?arg2 ) )

Intended domains : The value space of xs:time for?arg. Mapping:Adds two xs:dayTimeDurations. Returns an xs:integer between 0 and 23, both inclusive, representing the hours component in the localized value of?arg. If an argument value is outside of the intended domain, the value of the function is left unspecified and can varyxs:dayTimeDuration.

3.6.1.31 func:subtract-dayTimeDurations (adapted from op:subtract-dayTimeDurations)

  • Schema:

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

Subtracts one semantic structure toxs:dayTimeDuration from another. 3.6.1.11 func:minutes-from-timeReturns an xs:dayTimeDuration.

3.6.1.32 func:multiply-dayTimeDuration (adapted from fn:minutes-from-timeop:multiply-dayTimeDuration)

  • Schema:

    (?arg; func:minutes-from-time(?arg(?arg1?arg2; func:multiply-dayTimeDuration(?arg1?arg2 ) )

Intended domains : The value space of xs:time for?arg. Mapping: ReturnsMultiplies an xs:integer between 0 and 59, both inclusive, representing the minutes component in the localized value of?arg. Ifxs:dayTimeDuration by a xs:double. Returns an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.12 func:seconds-from-timexs:dayTimeDuration.

3.6.1.33 func:divide-dayTimeDuration (adapted from fn:seconds-from-timeop:divide-dayTimeDuration)

  • Schema:

    (?arg; func:seconds-from-time(?arg(?arg1?arg2; func:divide-dayTimeDuration(?arg1?arg2 ) )

Intended domainsDivides an xs:dayTimeDuration by an xs:double. Returns an xs:dayTimeDuration.

3.6.1.34 func:divide-dayTimeDuration-by-dayTimeDuration (adapted from op:divide-dayTimeDuration-by-dayTimeDuration)

  • Schema:

    The value space of xs:time for?arg. Mapping:(?arg1?arg2; func:divide-dayTimeDuration-by-dayTimeDuration(?arg1?arg2 ) )

Divides an xs:dayTimeDuration by an xs:dayTimeDuration. Returns an xs:decimal value greater than or equal to zero and less than 60, representing the seconds and fractional seconds in the localized value of?arg. If an argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.13 func:years-from-duration.

3.6.1.35 func:add-yearMonthDuration-to-dateTime (adapted from fn:years-from-durationop:add-yearMonthDuration-to-dateTime)

  • Schema:

    (?arg; func:years-from-duration(?arg(?arg1?arg2; func:add-yearMonthDuration-to-dateTime(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable toAdds a xs:yearMonthDuration according(?arg2) to the table in Section 17.1 of [XPath-Functions]. Mapping:a xs:dateTime (?arg1). Returns an xs:integer representing the years component in the value of?arg. The result is obtained by casting?argxs:dateTime.

3.6.1.36 func:add-yearMonthDuration-to-date (adapted from op:add-yearMonthDuration-to-date)

  • Schema:

    (?arg1?arg2; func:add-yearMonthDuration-to-date(?arg1?arg2 ) )

Adds a xs:yearMonthDuration (?arg2) to a xs:date (?arg1). Returns an xs:yearMonthDuration and then computing the years component. If the argument value is outside of the intended domain, the value of the function is left unspecified and can varyxs:date.

3.6.1.37 func:add-dayTimeDuration-to-dateTime (adapted from one semantic structureop:add-dayTimeDuration-to-dateTime)

  • Schema:

    (?arg1?arg2; func:add-dayTimeDuration-to-dateTime(?arg1?arg2 ) )

Adds a xs:dayTimeDuration (?arg2) to another. 3.6.1.14 func:months-from-durationa xs:dateTime (?arg1). Returns an xs:dateTime.

3.6.1.38 func:add-dayTimeDuration-to-date (adapted from fn:months-from-durationop:add-dayTimeDuration-to-date)

  • Schema:

    (?arg; func:months-from-duration(?arg(?arg1?arg2; func:add-dayTimeDuration-to-date(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable to xs:yearMonthDuration accordingAdds a xs:dayTimeDuration (?arg2) to the table in Section 17.1 of [XPath-Functions]. Mapping:a xs:date (?arg1). Returns an xs:integer representing the months component in the value of?arg. The result is obtained by casting?arg to an xs:yearMonthDuration and then computing the months component. If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.15 func:days-from-durationxs:date.

3.6.1.39 func:add-dayTimeDuration-to-time (adapted from fn:days-from-durationop:add-dayTimeDuration-to-time)

  • Schema:

    (?arg; func:days-from-duration(?arg(?arg1?arg2; func:add-dayTimeDuration-to-time(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable toAdds a xs:dayTimeDuration according(?arg2) to the table in Section 17.1 of [XPath-Functions]. Mapping:a xs:time (?arg1). Returns an xs:integer representing the days component in the value of?arg. The result is obtained by casting?arg to an xs:dayTimeDuration and then computing the days component. If the argument value is outside of the intended domain, the value of the function is left unspecified and can varyxs:time.

3.6.1.40 func:subtract-yearMonthDuration-from-dateTime (adapted from one semantic structure to another. 3.6.1.16 func:hours-from-durationop:subtract-yearMonthDuration-from-dateTime)

  • Schema:

    (?arg1?arg2; func:subtract-yearMonthDuration-from-dateTime(?arg1?arg2 ) )

Subtracts a xs:yearMonthDuration (?arg2) from a xs:dateTime (?arg1). Returns an xs:dateTime.

3.6.1.41 func:subtract-yearMonthDuration-from-date (adapted from fn:hours-from-durationop:subtract-yearMonthDuration-from-date)

  • Schema:

    (?arg; func:hours-from-duration(?arg(?arg1?arg2; func:subtract-yearMonthDuration-from-date(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable to xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions]. Mapping:Subtracts a xs:yearMonthDuration (?arg2) from a xs:date (?arg1). Returns an xs:integer representing the hours component in the value of?arg. The result is obtained by casting?arg to an xs:dayTimeDuration and then computing the hours component. If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary from one semantic structure to another. 3.6.1.17 func:minutes-from-durationxs:date.

3.6.1.42 func:subtract-dayTimeDuration-from-dateTime (adapted from fn:minutes-from-durationop:subtract-dayTimeDuration-from-dateTime)

  • Schema:

    (?arg; func:minutes-from-duration(?arg(?arg1?arg2; func:subtract-dayTimeDuration-from-dateTime(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable toSubtracts a xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions]. Mapping:(?arg2) from a xs:dateTime (?arg1). Returns an xs:integer representing the minutes component in the value of?arg. The result is obtained by casting?arg to anxs:dateTime.

3.6.1.43 func:subtract-dayTimeDuration-from-date (adapted from op:subtract-dayTimeDuration-from-date)

  • Schema:

    (?arg1?arg2; func:subtract-dayTimeDuration-from-date(?arg1?arg2 ) )

Subtracts a xs:dayTimeDuration and then computing the minutes component. If the argument value is outside of the intended domain, the value of the function is left unspecified and can vary(?arg2) from one semantic structure to another. 3.6.1.18 func:seconds-from-durationa xs:date (?arg1). Returns an xs:date.

3.6.1.44 func:subtract-dayTimeDuration-from-time (adapted from fn:seconds-from-durationop:subtract-dayTimeDuration-from-time)

  • Schema:

    (?arg; func:seconds-from-duration(?arg(?arg1?arg2; func:subtract-dayTimeDuration-from-time(?arg1?arg2 ) )

Intended domains : The union of the value spaces of datatypes castable toSubtracts a xs:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions]. Mapping:(?arg2) from a xs:time (?arg1). Returns an xs:decimal representing the seconds component in the value of?arg. The result is obtained by casting?arg to an xs:dayTimeDuration and then computing the seconds component. If the argument value is outside of the intended domain, the value of the function is left unspecifiedxs:time.

3.6.2 Predicates on Dates, Times, and can vary from one semantic structure to another. 3.6.1.19 func:timezone-from-dateTimeDurations

3.6.2.1 pred:dateTime-equal (adapted from fn:timezone-from-dateTimeop:dateTime-equal)

  • Schema:

    (?arg; func:timezone-from-dateTime(?arg(?arg1?arg2; pred:dateTime-equal(?arg1?arg2) )

  • Intended domains:

    The value space of xs:dateTime .for both arguments.

  • Mapping:

    Returns the timezone component of?argWhen both s1 and s2 belong to their intended domains, Itruth Iexternal(?arg1?arg2; pred:dateTime-equal(?arg1?arg2 ) )(s1 s2) = t

    if any.and only if $arg has a timezone component, then the resultop:dateTime-equal(s1, s2) returns true, as defined in [XPath-Functions], f in case false is an xs:dayTimeDuration that indicates deviation from UTC; its value may range from +14:00 to -14:00 hours, both inclusive.returned.

    If thean argument value is outside of the intended domain, the truth value of the function is left unspecified and can vary from one semantic structure to another.

The following two functionsschemata for comparison operators are defined analogously with respect to their corresponding operators as defined in [XPath-Functions], where the intended domain for both arguments is implicit by the operator name and we only give additional details on intended domains xs:dateand xs:time 3.6.1.20 func:timezone-from-datemapping as needed.

3.6.2.2 pred:dateTime-less-than (adapted from fn:timezone-from-dateop:dateTime-less-than)

  • Schema:

    (?arg; func:timezone-from-date(?arg(?arg1?arg2; pred:dateTime-less-than(?arg1?arg2 ) )

3.6.1.21 func:timezone-from-time3.6.2.3 pred:dateTime-greater-thanl (adapted from fn:timezone-from-timeop:dateTime-greater-than)

  • Schema:

    (?arg; func:timezone-from-time(?arg(?arg1?arg2; pred:dateTime-greater-than(?arg1?arg2 ) )

3.6.1.22 func:subtract-dateTimes3.6.2.4 pred:date-equal (adapted from op:subtract-dateTimesop:date-equal)

  • Schema:

    (?arg1?arg2; func:subtract-dateTimes(?argpred:date-equal(?arg1?arg2) )

Subtracts two xs:dateTime s. Returns an xs:xs:dayTimeDuration . 3.6.1.23 func:subtract-dates3.6.2.5 pred:date-less-than (adapted from op:subtract-datesop:date-less-than)

  • Schema:

    (?arg1?arg2; func:subtract-dates(?argpred:date-less-than(?arg1?arg2 ) )

Subtracts two xs:date s. Returns an xs:xs:dayTimeDuration . 3.6.1.24 func:subtract-times3.6.2.6 pred:date-greater-than (adapted from op:subtract-timesop:date-greater-than)

  • Schema:

    (?arg1?arg2; func:subtract-times(?argpred:date-greater-than(?arg1?arg2 ) )

Subtracts two xs:time s. Returns an xs:xs:dayTimeDuration . 3.6.1.25 func:add-yearMonthDurations3.6.2.7 pred:time-equal (adapted from op:add-yearMonthDurationsop:time-equal)

  • Schema:

    (?arg1?arg2; func:add-yearMonthDurations(?argpred:time-equal(?arg1?arg2) )

Adds two xs:yearMonthDuration s. Returns an xs:yearMonthDuration . 3.6.1.26 func:subtract-yearMonthDurations3.6.2.8 pred:time-less-than (adapted from op:subtract-yearMonthDurationsop:time-less-than)

  • Schema:

    (?arg1?arg2; func:subtract-yearMonthDurations(?argpred:time-less-than(?arg1?arg2 ) )

Subtracts one xs:yearMonthDuration3.6.2.9 pred:time-greater-than (adapted from another. Returns an xs:yearMonthDuration . 3.6.1.27 func:multiply-yearMonthDurationop:time-greater-than)

  • Schema:

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

3.6.2.10 pred:duration-equal (adapted from op:multiply-yearMonthDurationop:duration-equal)

  • Schema:

    (?arg1?arg2; func:multiply-yearMonthDuration(?argpred:duration-equal(?arg1?arg2) )

  • Multiplies an xs:yearMonthDuration by an xs:double . Returns anIntended domains:

    The union of the value spaces of xs:dayTimeDuration and xs:yearMonthDuration . 3.6.1.28 func:divide-yearMonthDurationfor both arguments.

3.6.2.11 pred:dateTimeDuration-less-than (adapted from op:divide-yearMonthDurationop:dayTimeDuration-less-than)

  • Schema:

    (?arg1?arg2; func:divide-yearMonthDuration(?argpred:dayTimeDuration-less-than(?arg1?arg2 ) )

Divides an xs:yearMonthDuration by an xs:double . Returns an xs:yearMonthDuration . 3.6.1.29 func:divide-by-yearMonthDuration3.6.2.12 pred:dayTimeDuration-greater-than (adapted from op:divide-yearMonthDuration-by-yearMonthDurationop:dayTimeDuration-greater-than)

  • Schema:

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

3.6.2.13 pred:yearMonthDuration-less-than (adapted from op:yearMonthDuration-less-than)

  • Schema:

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

3.6.2.14 pred:yearMonthDuration-greater-than (adapted from op:yearMonthDuration-greater-than)

  • Schema:

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

3.6.2.15 pred:dateTime-not-equal

  • Schema:

    (?arg1?arg2; func:divide-yearMonthDuration-by-yearMonthDuration(?argpred:dateTime-not-equal(?arg1?arg2) )

Divides an xs:yearMonthDuration by an xs:yearMonthDuration . Returns an xs:decimal . 3.6.1.30 func:add-dayTimeDurations (adapted from op:add-dayTimeDurations )The predicate pred:dateTime-not-equal has the same intended domains as pred:dateTime-equal and is true whenever pred:dateTime-equal is false.

3.6.2.16 pred:dateTime-less-than-or-equal

  • Schema:

    (?arg1?arg2; func:add-dayTimeDurations(?argpred:dateTime-less-than-or-equal(?arg1?arg2) )

Adds two xs:dayTimeDuration s. Returns an xs:dayTimeDuration . 3.6.1.31 func:subtract-dayTimeDurations (adapted from op:subtract-dayTimeDurations )The predicate pred:dateTime-less-than-or-equal has the same intended domains as pred:dateTime-equal and is true whenever pred:dateTime-equal is true or pred:dateTime-less-than is true.

3.6.2.17 pred:dateTime-greater-than-or-equal

  • Schema:

    (?arg1?arg2; func:subtract-dayTimeDurations(?argpred:dateTime-greater-than-or-equal(?arg1?arg2) )

Subtracts one xs:dayTimeDuration from another. Returns an xs:dayTimeDuration . 3.6.1.32 func:multiply-dayTimeDuration (adapted from op:multiply-dayTimeDuration )The predicate pred:dateTime-greater-than-or-equal has the same intended domains as pred:dateTime-equal and is true whenever pred:dateTime-equal is true or pred:dateTime-greater-than is true.

3.6.2.18 pred:date-not-equal

  • Schema:

    (?arg1?arg2; func:multiply-dayTimeDuration(?argpred:date-not-equal(?arg1?arg2) )

Multiplies an xs:dayTimeDuration by a xs:double . Returns an xs:dayTimeDuration . 3.6.1.33 func:divide-dayTimeDuration (adapted from op:divide-dayTimeDuration )The predicate pred:date-not-equal has the same intended domains as pred:date-equal and is true whenever pred:date-equal is false.

3.6.2.19 pred:date-less-than-or-equal

  • Schema:

    (?arg1?arg2; func:divide-dayTimeDuration(?argpred:date-less-than-or-equal(?arg1?arg2) )

Divides an xs:dayTimeDuration by an xs:double . Returns an xs:dayTimeDuration . 3.6.1.34 func:divide-dayTimeDuration-by-dayTimeDuration (adapted from op:divide-dayTimeDuration-by-dayTimeDuration )The predicate pred:date-less-than-or-equal has the same intended domains as pred:date-equal and is true whenever pred:date-equal is true or pred:date-less-than is true.

3.6.2.20 pred:date-greater-than-or-equal

  • Schema:

    (?arg1?arg2; func:divide-dayTimeDuration-by-dayTimeDuration(?argpred:date-greater-than-or-equal(?arg1?arg2) )

Divides an xs:dayTimeDuration by an xs:dayTimeDuration . Returns an xs:decimal . 3.6.1.35 func:add-yearMonthDuration-to-dateTime (adapted from op:add-yearMonthDuration-to-dateTimeThe predicate pred:date-greater-than-or-equal has the same intended domains as pred:date-equal and is true whenever pred:date-equal is true or pred:date-greater-than is true.

3.6.2.21 pred:time-not-equal

  • Schema:

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

The predicate pred:time-not-equal has the same intended domains as pred:time-equal and is true whenever pred:time-equal is false.

3.6.2.22 pred:time-less-than-or-equal

  • Schema:

    (?arg1?arg2; func:add-yearMonthDuration-to-dateTime(?argpred:time-less-than-or-equal(?arg1?arg2) )

Adds a xs:yearMonthDuration ( ?arg 2 ) to a xs:dateTime ( ?arg 1 ). Returns an xs:dateTime . 3.6.1.36 func:add-yearMonthDuration-to-date (adapted from op:add-yearMonthDuration-to-date )The predicate pred:time-less-than-or-equal has the same intended domains as pred:time-equal and is true whenever pred:time-equal is true or pred:time-less-than is true.

3.6.2.23 pred:time-greater-than-or-equal

  • Schema:

    (?arg1?arg2; func:add-yearMonthDuration-to-date(?argpred:time-greater-than-or-equal(?arg1?arg2) )

Adds a xs:yearMonthDuration ( ?arg 2 ) to a xs:date ( ?arg 1 ). Returns an xs:date . 3.6.1.37 func:add-dayTimeDuration-to-dateTime (adapted from op:add-dayTimeDuration-to-dateTime )The predicate pred:time-greater-than-or-equal has the same intended domains as pred:time-equal and is true whenever pred:time-equal is true or pred:time-greater-than is true.

3.6.2.24 pred:duration-not-equal

  • Schema:

    (?arg1?arg2; func:add-dayTimeDuration-to-dateTime(?argpred:duration-not-equal(?arg1?arg2) )

Adds a xs:dayTimeDuration ( ?arg 2 ) toThe predicate pred:duration-equal has the same intended domains as pred:duration-equal and is true whenever pred:duration-equal is false.


Editor's Note: The introduction of less-than-or-eaual and greater-than-or-equal predicates for dayTimeDuration and yearMonthDuration still needs a xs:dateTime ( ?arg 1 ). Returns an xs:dateTime . 3.6.1.38 func:add-dayTimeDuration-to-date (adapted from op:add-dayTimeDuration-to-date )WG resolution.

3.6.2.25 pred:dayTimeDuration-less-than-or-equal

  • Schema:

    (?arg1?arg2; func:add-dayTimeDuration-to-date(?argpred:dayTimeDuration-less-than-or-equal(?arg1?arg2) )

Adds a xs:dayTimeDuration ( ?arg 2 ) to a xs:date ( ?arg 1 ). Returns an xs:date . 3.6.1.39 func:add-dayTimeDuration-to-time (adapted from op:add-dayTimeDuration-to-time )The predicate pred:dayTimeDuration-less-than-or-equal has the same intended domains as pred:dayTimeDuration-less-than and is true whenever pred:duration-equal is true or pred:dayTimeDuration-less-than is true.

3.6.2.26 pred:dayTimeDuration-greater-than-or-equal

  • Schema:

    (?arg1?arg2; func:add-dayTimeDuration-to-time(?argpred:dayTimeDuration-greater-than(?arg1?arg2) )

Adds a xs:dayTimeDuration (The predicate pred:dayTimeDuration-greater-than-or-equal has the same intended domains as pred:dayTimeDuration-greater-than and is true whenever pred:duration-equal is true or pred:dayTimeDuration-greater-than is true.

3.6.2.27 pred:yearMonthDuration-less-than-or-equal

  • Schema:

    (?arg1?arg2 ) to a xs:time ( ?arg; pred:yearMonthDuration-less-than-or-equal(?arg1 ). Returns an xs:time . 3.6.1.40 func:subtract-yearMonthDuration-from-dateTime (adapted from op:subtract-yearMonthDuration-from-dateTime?arg2) )

The predicate pred:yearMonthDuration-less-than-or-equal has the same intended domains as pred:yearMonthDuration-less-than and is true whenever pred:duration-equal is true or pred:yearMonthDuration-less-than is true.

3.6.2.28 pred:yearMonthDuration-greater-than-or-equal

  • Schema:

    (?arg1?arg2; func:subtract-yearMonthDuration-from-dateTime(?argpred:yearMonthDuration--greater-than(?arg1?arg2) )

Subtracts a xs:yearMonthDuration ( ?arg 2 )The predicate pred:yearMonthDuration-greater-than-or-equal has the same intended domains as pred:yearMonthDuration-greater-than and is true whenever pred:duration-equal is true or pred:yearMonthDuration-greater-than is true.

3.7 Functions and Predicates on rdf:XMLLiterals

Editor's Note: Predicates for rdf:XMLLiteral such as at least comparison predicates (equals, not-equals) are still under discussion in the working group.


3.8 Functions and Predicates on rdf:text

The following functions and predicates are adapted from a xs:dateTime ( ?arg 1 ). Returns an xs:dateTimethe respective functions and operators in [RDF-TEXT].

Editor's Note: Issues which are still open in the rdf:text specification might imply future changes on the functions and predicates defined here. For instance reuse of the fn: namespace is still under discussion, cf. http://lists.w3.org/Archives/Public/public-rdf-text/2008OctDec/0020.html. 3.6.1.41 func:subtract-yearMonthDuration-from-dateMoreover, references and links to the [RDF-TEXT] document will be updated in future versions of this document.

3.8.1 Functions on rdf:text

3.8.1.1 func:text-from-string-lang (adapted from op:subtract-yearMonthDuration-from-datefn:text-from-string-lang)

  • Schema:

    (?arg1?arg2; func:subtract-yearMonthDuration-from-date(?argfunc:text-from-string-lang(?arg1?arg2 ) )

  • Subtracts a xs:yearMonthDuration (Intended domains:

    The value space of xs:string for?arg1 and the intersection of the elements of the value space of xs:string which represent valid language tags according to [BCP-47] for?arg2.

  • Mapping:

    Iexternal((?arg1?arg2; func:text-from-string-lang(?arg1?arg2 ) from a xs:date)(s l) = res such that res is the pair ( ?arg 1 ). Returns an xs:dates, l ) in the value space of rdf:text.

    3.6.1.42 func:subtract-dayTimeDuration-from-dateTimeIf any argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

3.8.1.2 func:text-from-string (adapted from op:subtract-dayTimeDuration-from-dateTimefn:text-from-string)

  • Schema:

    (?arg 1 ?arg 2 ; func:subtract-dayTimeDuration-from-dateTime(?arg 1 ?arg 2(?arg; func:text-from-string(?arg ) )

  • Subtracts a xs:dayTimeDurationIntended domain:

    The value space of xs:string for?arg.

  • Mapping:

    Iexternal( ?arg 2(?arg; func:text-from-string(?arg ) from a xs:dateTime)(s) = res such that res is the pair ( ?arg 1 ). Returns an xs:dateTimes, "" ) in the value space of rdf:text.

    3.6.1.43 func:subtract-dayTimeDuration-from-dateIf the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from one semantic structure to another.

Note: Since RIF implementations MAY choose to interpret xs:string and its subtypes as subtypes of rdf:text following Section 3.1 of [RDF-TEXT], in such implementations this function may just be implemented as the identity function.

3.8.1.3 func:string-from-text (adapted from op:subtract-dayTimeDuration-from-datefn:string-from-text)

  • Schema:

    (?arg 1 ?arg 2 ; func:subtract-dayTimeDuration-from-date(?arg 1 ?arg 2(?arg; func:string-from-text(?arg ) )

  • Subtracts a xs:dayTimeDuration ( ?arg 2Intended domain:

    The value space of rdf:text for?arg.

  • Mapping:

    Iexternal(?arg; func:string-from-text(?arg ) )(t) = res such that res is the string part s of t if t=( s, l ) is in the intended domain.

    If the argument value is outside of its intended domain, the value of the function is left unspecified and can vary from a xs:date ( ?arg 1 ). Returns an xs:date . 3.6.1.44 func:subtract-dayTimeDuration-from-timeone semantic structure to another.

3.8.1.4 func:lang-from-text (adapted from op:subtract-dayTimeDuration-from-timefn:lang-from-text)

  • Schema:

    (?arg 1 ?arg 2 ; func:subtract-dayTimeDuration-from-time(?arg 1 ?arg 2(?arg; func:lang-from-text(?arg ) )

  • Subtracts a xs:dayTimeDuration ( ?arg 2Intended domain:

    The value space of rdf:text for?arg.

  • Mapping:

    Iexternal(?arg; func:lang-from-text(?arg ) from a xs:time ( ?arg 1 ). Returns an xs:time . 3.6.2 Predicates on Dates, Times,)(t) = l such that l is the language tag string of t if t= ( s, l ) is in the intended domain and Durations 3.6.2.1 pred:dateTime-equal""^^xs:string otherwise.

3.8.1.5 func:text-compare (adapted from op:dateTime-equalfn:text-compare)

  • Schema:

    (?arg(?comparand1 ?arg?comparand2; pred:dateTime-equal(?argfunc:text-compare1(?comparand1 ?arg?comparand2) )

    (?comparand1?comparand2?collation; func:text-compare2(?comparand1?comparand2?collation) )

  • Intended domains:

    The value space of xs:dateTimerdf:text for both arguments.?comparand1 and $comparand2, and the value space of xs:string for ?collation.

  • Mapping:

    where I truthIexternal (?arg( (?comparand1 ?arg?comparand2; pred:dateTime-equal(?argfunc:text-compare1(?comparand1 ?arg?comparand2) )(s)(t1 st2) = res such that, whenever t if and only if op:dateTime-equal (s1=( s1, l ) and t2=( s2 ) returns true, as definedl ) are two pairs with the same language tag l in [ XPath-Functions ], fthe value space ofrdf:text, res = -1, 0, or 1 (from the value space of xs:integer), depending on whether the value of s1 is respectively less than, equal to, or greater than the value of s2 according to the rules of the collation that is used.

    In case falsean argument value is returned.outside of the intended domain, or if the language tags of the values for ?comparand1 and $comparand2 differ, the function value is left unspecified and can vary from one semantic structure to another.

3.8.1.6 func:text-length (adapted from fn:text-length)

  • Schema:

    ( func:text-length1() )

    (?arg; func:text-length2(?arg ) )

  • Intended domains:

    The value space of rdf:text for?arg.

  • Mapping:

    Returns an xs:integer equal to the length in characters of the string part s of the argument if it is a pair ( s,l ) in the value space of rdf:text, returns 0 when called without an argument.

    If the argument value is outside of theits intended domain, the truthvalue of the function is left unspecified and can vary from one semantic structure to another.

3.8.2 Predicates on rdf:text

3.8.2.1 pred:matches-language-range (adapted from fn:matches-language-range)

  • Schema:

    (?input?range; pred:matches-language-range(?input?range) )

  • Intended domains:

    The following schematavalue space of rdf:text for comparison operators are defined analogously with respect to their corresponding operators as defined in [ XPath-Functions ], where?input and the intended domainvalue space of xs:string for all ?range.

  • Mapping:

    Whenever both arguments is implicit by the operator nameare in their intended domains, returns true if and weonly give additional details on intended domainsif the language tag of ?input is a valid language tag according to BCP-47 [BCP-47], and mappingif it matches the language-range expression supplied as needed. 3.6.2.2 pred:dateTime-less-than (adapted from op:dateTime-less-than ) Schema : (?arg 1 ?arg 2 ; pred:dateTime-less-than(?arg 1 ?arg 2 ) ) 3.6.2.3 pred:dateTime-greater-thanl (adapted from op:dateTime-greater-than ) Schema : (?arg 1 ?arg 2 ; pred:dateTime-greater-than(?arg 1 ?arg 2 ) ) 3.6.2.4 pred:date-equal (adapted from op:date-equal ) Schema : (?arg 1 ?arg 2 ; pred:date-equal(?arg 1 ?arg 2 ) ) 3.6.2.5 pred:date-less-than (adapted from op:date-less-than ) Schema : (?arg 1 ?arg 2 ; pred:date-less-than(?arg 1 ?arg 2 ) ) 3.6.2.6 pred:date-greater-than (adapted from op:date-greater-than ) Schema : (?arg 1 ?arg 2 ; pred:date-greater-than(?arg 1 ?arg 2 ) ) 3.6.2.7 pred:time-equal (adapted from op:time-equal ) Schema : (?arg 1 ?arg 2 ; pred:time-equal(?arg 1 ?arg 2 ) ) 3.6.2.8 pred:time-less-than (adapted from op:time-less-than ) Schema : (?arg 1 ?arg 2 ; pred:time-less-than(?arg 1 ?arg 2 ) ) 3.6.2.9 pred:time-greater-than (adapted from op:time-greater-than ) Schema : (?arg 1 ?arg 2 ; pred:time-greater-than(?arg 1 ?arg 2 ) ) 3.6.2.10 pred:duration-equal (adapted?range as specified by the algorithm for "Matching of Language Tags" which is part of BCP-47 [BCP-47]; otherwise, it returns false.

    If an argument value is outside of the intended domain, the truth value of the predicate is left unspecified and can vary from op:duration-equal )one semantic structure to another.

Following the convention of having separate equality, inequality, less-than, greater-than, less-than-or-equal, greater-than-or-equal predicates for other datatypes, RIF defines such predicates as syntactic sugar over func:text-compare also for rdf:text in the following.

3.8.2.2 pred:text-equal

  • Schema:

    (?arg(?comparand1 ?arg?comparand2; pred:duration-equal(?argpred:text-equal(?comparand1 ?arg?comparand2) )

  • Intended domains:

    The union of thevalue spacesspace of xs:dayTimeDuration and xs:yearMonthDurationrdf:text for both arguments.

  • 3.6.2.11 pred:dateTimeDuration-less-than (adapted from op:dayTimeDuration-less-than ) Schema : (?arg 1 ?arg 2 ; pred:dayTimeDuration-less-than(?argMapping:

    When both s1 ?argand s2 ) ) 3.6.2.12 pred:dayTimeDuration-greater-than (adapted from op:dayTimeDuration-greater-than ) Schema : (?argbelong to their intended domains, Itruth Iexternal( (?comparand1 ?arg?comparand2; pred:dayTimeDuration-greater-than(?argpred:text-equal(?comparand1 ?arg?comparand2) ) 3.6.2.13 pred:yearMonthDuration-less-than (adapted from op:yearMonthDuration-less-than ) Schema : (?arg 1 ?arg 2 ; pred:yearMonthDuration-less-than(?arg)(s1 ?args2) ) 3.6.2.14 pred:yearMonthDuration-greater-than (adapted from op:yearMonthDuration-greater-than ) Schema : (?arg= t if and only if Iexternal( (?comparand1 ?arg?comparand2; pred:yearMonthDuration-greater-than(?argpred:text-compare(?comparand1 ?arg?comparand2) ) 3.6.2.15 pred:dateTime-not-equal Schema : (?arg 1 ?arg 2 ; pred:dateTime-not-equal(?arg)(s1 ?args2) ) 3.6.2.16 pred:dateTime-less-than-or-equal= 0.

    If an argument value is outside of the intended domain, the value of the truth value of the predicate is left unspecified and can vary from one semantic structure to another.

3.8.2.3 pred:text-less-than

  • Schema:

    (?arg(?comparand1 ?arg?comparand2; pred:dateTime-less-than-or-equal(?argpred:text-less-than(?comparand1 ?arg?comparand2) )

  • 3.6.2.17 pred:dateTime-greater-than-or-equal SchemaIntended domains:

    (?arg 1 ?arg 2 ; pred:dateTime-greater-than-or-equal(?argThe value space of rdf:text for both arguments.

  • Mapping:

    When both s1 ?argand s2 ) ) 3.6.2.18 pred:date-not-equal Schema : (?argbelong to their intended domains, Itruth Iexternal( (?comparand1 ?arg?comparand2; pred:date-not-equal(?argpred:text-less-than(?comparand1 ?arg?comparand2) ) 3.6.2.19 pred:date-less-than-or-equal Schema : (?arg 1 ?arg 2 ; pred:date-less-than-or-equal(?arg)(s1 ?args2) ) 3.6.2.20 pred:date-greater-than-or-equal Schema : (?arg= t if and only if Iexternal( (?comparand1 ?arg?comparand2; pred:date-greater-than-or-equal(?argpred:compare(?comparand1 ?arg?comparand2) ) 3.6.2.21 pred:time-not-equal Schema : (?arg 1 ?arg 2 ; pred:time-not-equal(?arg)(s1 ?args2) ) 3.6.2.22 pred:time-less-than-or-equal= -1.

    If an argument value is outside of the intended domain, the value of the truth value of the predicate is left unspecified and can vary from one semantic structure to another.

3.8.2.4 pred:text-greater-than

  • Schema:

    (?arg(?comparand1 ?arg?comparand2; pred:time-less-than-or-equal(?argpred:text-greater-than(?comparand1 ?arg?comparand2) )

  • 3.6.2.23 pred:time-greater-than-or-equal SchemaIntended domains:

    (?argThe value space of rdf:text for both arguments.

  • Mapping:

    When both s1 ?argand s2 belong to their intended domains, Itruth Iexternal( (?comparand1?comparand2; pred:time-greater-than-or-equal(?argpred:text-greater-than(?comparand1 ?arg?comparand2) )(s1 s2) 3.6.2.24 pred:duration-not-equal Schema : (?arg= t if and only if Iexternal( (?comparand1 ?arg?comparand2; pred:duration-not-equal(?argpred:compare(?comparand1 ?arg?comparand2) )(s1 s2) Editor's Note: No less-than-or-equal or greater-than-or-equal predicates are defined in this draft for durations, since there are no separate op:dayTimeDuration-equal nor op:yearMonthDuration-equal predicates in [ XPath-Functions ], but only a common predicate op:duration-equal . Future versions= 1.

    If an argument value is outside of this working draft may resolve this by introducing new equality predicates pred:dayTimeDuration-equal and pred:yearMonthDuration-equal with restricted intended domains. 3.7 Functions and Predicates on rdf:XMLLiterals Editor's Note: Predicates for rdf:XMLLiteral such as at least comparison predicates (equals, not-equals) are still under discussion in the working group. 3.8 Functions and Predicates on rif:textthe following function serves to extractintended domain, the language tag from values invalue of the rif:texttruth value space. 3.8.1 func:lang (adaptedof the predicate is left unspecified and can vary from SPARQL's lang function )one semantic structure to another.

The following built-in predicates pred:text-not-equal, pred:text-less-than-or-equal and text:text-greater-than-or-equal are defined accordingly.

3.8.2.5 pred:text-not-equal

  • Schema:

    (?arg; func:lang(?arg(?comparand1?comparand2; pred:text-not-equal(?comparand1?comparand2) )

The predicate pred:text-not-equal has the same intended domains as pred:text-equal and is true whenever pred:text-equal is false.

3.8.2.6 pred:text-less-than-or-equal

  • Schema:

    The value space of rif:text for?arg. Mapping: I external (?arg; func:lang(?arg(?comparand1?comparand2; pred:text-less-than-or-equal(?comparand1?comparand2) )

)(s) = res such that res isThe language tag string of s, if s is inpredicate pred:text-less-than-or-equal has the value space of rif:textsame intended domains as pred:text-equal and ""^^xs:string otherwise. Editor's Note: The current name of this functionis still under disscussion in the working group. Alternative proposals include e.g. func:lang-from-text , which followstrue whenever pred:text-equal is true or pred:text-less-than is true.

3.8.2.7 pred:text-greater-than-or-equal

  • Schema:

    (?comparand1?comparand2; pred:text-greater-than-or-equal(?comparand1?comparand2) )

The XPath/XQuery naming convention for extraction functions from datatypes thanpredicate pred:text-greater-than-or-equal has the SPARQL naming convention. Editor's Note: We have not yet included comparison predicates (equal, less-than, greater-than,same intended domains as pred:text-equal and is true whenever pred:text-equal is true or compare ...) for rif:text . Future versions of this document might introduce these.pred:text-greater-than is true.

4 References

[BCP-47]
BCP 47 - Tags for the Identification of Languages, A. Phillips, M. Davis, IETF, Sep 2006, ftp://ftp.rfc-editor.org/in-notes/bcp/bcp47.txt.

[BLD]
RIF Basic Logic Dialect Harold, H. Boley, Michael Kifer, eds.M. Kifer (Editors), W3C Editor's Draft, 22 September 2008, http://www.w3.org/2005/rules/wg/draft/ED-rif-bld-20080922/ .Working Draft. Latest version available at http://www.w3.org/2005/rules/wg/draft/rif-bld/ .http://www.w3.org/2005/rules/wiki/BLD (Reference will be adapted at publication time.).

[CURIE]
CURIE Syntax 1.0: A syntax for expressing Compact URIs, MarkM. Birbeck, ShaneS. McCarron. W3C Working Draft 2 April 2008. Available at http://www.w3.org/TR/curie/.

[RDF-CONCEPTS]
Resource Description Framework (RDF): Concepts and Abstract Syntax, Klyne G., CarrollG. Klyne, J. Carroll (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, PatrickP. 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, BrianB. McBride, Editor, W3C Recommendation 10 February 2004, http://www.w3.org/TR/2004/REC-rdf-schema-20040210/. Latest version available at http://www.w3.org/TR/rdf-schema/.

[RDF-TEXT]
rdf:text: A Datatype for Internationalized Text , J. Bao, A. Polleres, B. Motik (Editors), W3C Working Draft. Latest version available at http://www.w3.org/2007/OWL/wiki/InternationalizedStringSpec.

(Reference will be adapted at publication time.)

[RFC-3986]
RFC 3986 - Uniform Resource Identifier (URI): Generic Syntax, T. Berners-Lee, R. Fielding, L. Masinter, IETF, January 2005, http://www.ietf.org/rfc/rfc3986.txt.

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

[SPARQL]
SPARQL Query Language for RDF, E. Prud'hommeaux, A. Seaborne (Editors), W3C Recommendation, World Wide Web Consortium, 12 January 2008, http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/. Latest version available at http://www.w3.org/TR/rdf-sparql-query/.

[XDM]
XQuery 1.0 and XPath 2.0 Data Model (XDM), M. Fernández, A. Malhotra, J. Marsh, M. Nagy, N. Walsh (Editors), W3C Recommendation, World Wide Web Consortium, 23 January 2007. This version is http://www.w3.org/TR/2007/REC-xpath-datamodel-20070123/. Latest version available at http://www.w3.org/TR/xpath-datamodel/.

[XML-NS]
Namespaces in XML 1.1 (Second Edition), T. Bray, D. Hollander, A. Layman, R. Tobin (Editors), W3C Recommendation, World Wide Web Consortium, 16 August 2006, http://www.w3.org/TR/2006/REC-xml-names11-20060816/. Latest version available at http://www.w3.org/TR/xml-names11/.

[XML-SCHEMA2]
XML Schema Part 2: Datatypes Second Edition, P. V. Biron, A. Malhotra (Editors), W3C Recommendation, World Wide Web Consortium, 28 October 2004, http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/. Latest version available at http://www.w3.org/TR/xmlschema-2/.

[XPath-Functions]
XQuery 1.0 and XPath 2.0 Functions and Operators, A. Malhotra, J. Melton, N. Walsh (Editors), W3C Recommendation, World Wide Web Consortium, 23 January 2007, http://www.w3.org/TR/2007/REC-xpath-functions-20070123/. Latest version available at http://www.w3.org/TR/xpath-functions/.

5 Appendix: Schemas for Externally Defined Terms

This section is an edited copy of a section from RIF Framework for Logic Dialects. It is reproduced here for convenience of readers familiar with the RIF-BLD document who might not have studied RIF-FLD.

This section defines external schemas, which serve as templates for externally defined terms. These schemas determine which externally defined terms are acceptable in a RIF dialect. Externally defined terms include RIF built-ins, but are more general. They are designed to also accommodate the ideas of procedural attachments and querying of external data sources. Because of the need to accommodate many difference possibilities, the RIF logical framework supports a very general notion of an externally defined term. Such a term is not necessarily a function or a predicate -- it can be a frame, a classification term, and so on.

Definition (Schema for external term). An external schema is a statement of the form (?X1 ...?Xn;) where

  • is a constant, a positional, named-argument, or a frame term.
  • ?X1 ...?Xn is a list of all distinct variables that occur in

The names of the variables in an external schema are immaterial, but their order is important. For instance, (?X?Y;?X[foo->?Y]) and (?V?W;?V[foo->?W]) are considered to be indistinguishable, but (?X?Y;?X[foo->?Y]) and (?Y?X;?X[foo->?Y]) are viewed as different schemas.

A term t is an instance of an external schema (?X1 ...?Xn;) iff t can be obtained from by a simultaneous substitution ?X1/s1 ...?Xn/sn of the variables ?X1 ...?Xn with terms s1 ... sn, respectively. Some of the terms si can be variables themselves. For example, ?Z[foo->f(a?P)] is an instance of (?X?Y;?X[foo->?Y]) by the substitution ?X/?Z?Y/f(a?P). ☐

Observe that a variable cannot be an instance of an external schema, since in the above definition cannot be a variable. It will be seen later that this implies that a term of the form External(?X) is not well-formed in RIF.

The intuition behind the notion of an external schema, such as (?X?Y;?X["foo"^^xs:string->?Y])(?X?Y;?X["foo"^^xs:string->?Y]) or (?V; "pred:isTime"^^rif:iri(?V))"pred:isTime"^^rif:iri(?V)), is that ?X["foo"^^xs:string->?Y]?X["foo"^^xs:string->?Y] or "pred:isTime"^^rif:iri(?V)"pred:isTime"^^rif:iri(?V) are invocation patterns for querying external sources, and instances of those schemas correspond to concrete invocations. Thus, External("http://foo.bar.com"^^rif:iri["foo"^^xs:string->"123"^^xs:integer])External("http://foo.bar.com"^^rif:iri["foo"^^xs:string->"123"^^xs:integer]) and External("pred:isTime"^^rif:iri("22:33:44"^^xs:time)External("pred:isTime"^^rif:iri("22:33:44"^^xs:time) are examples of invocations of external terms -- one querying an external source and another invoking a built-in.


Definition (Coherent set of external schemas). A set of external schemas is coherent if there is no term, t, that is an instance of two distinct schemas in the set. ☐

The intuition behind this notion is to ensure that any use of an external term is associated with at most one external schema. This assumption is relied upon in the definition of the semantics of externally defined terms. Note that the coherence condition is easy to verify syntactically and that it implies that schemas like (?X?Y;?X[foo->?Y]) and (?Y?X;?X[foo->?Y]), which differ only in the order of their variables, cannot be in the same coherent set.

It is important to keep in mind that external schemas are not part of the language in RIF, since they do not appear anywhere in RIF statements. Instead, they are best thought of as part of the grammar of the language.