Copyright © 2008 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
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 56 documents:
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.
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.
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 supportedrequired by RIF dialects
such as the RIF Basic
Logic Dialect. This list shall be viewed as a catalogue which
dialects can use by referencing which datatypes and builtins must
be supported by implementations of these specific dialects. Some of
the RIF supporteddatatypes are adopted from XML Schema Part 2: Datatypes Second Edition .[XML-SCHEMA2]. A large part of the definitions of the listed
functions and operators are adapted from XQuery 1.0 and XPath 2.0 Functions and Operators .[XPath-Functions].
Throughout this document we use the following prefixes for
compact IRIs [CURIE] used
for symbol spaces:spaces or for IRI constants in RIF's presentation
syntax:
This section reproduces the definition ofEach constant (that is, each non-keyword symbol) in RIF belongs
to a particular symbol spaces, which arespace. To refer to a constant in a
particular RIF symbol space, we use the following presentation
syntax:
"literal"^^<identifier>
where literal is called the lexical
part of the syntacticsymbol, and semantic framework for RIF's logic-based dialects . Definition (Symbol space). Aidentifier is an
IRI identifying the symbol spacespace. Here literal is a
named subset ofUnicode string that must be an element in the setlexical space of the
symbol space identified by IRI.
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. They are part of the logical RIF framework (RIF-FLD).Each symbol in
Const belongs to exactly one symbol space.
Each symbol space has an associated lexical space,space and a unique
identifier, and, possibly, one or more aliases.IRI identifying it. More precisely,
An alias is also a sequence of unicode characters, but it is not required to form an IRI. Different symbol spaces cannot share the same identifier or an alias.The identifiers and aliasesof symbol spaces are not themselves
constant symbols in RIF. ☐However, to simplify the language, we will
often use symbol space identifiers to refer to the actual symbol
spaces (for instance, we may use "symbol space xsd:string"
instead of "symbol space identified by
xsd:string").
To refer to a constant in a particular RIF symbol space, we use the following presentation syntax: "literal"^^symspace where literal is called the lexical part of the symbol, and symspace is an identifier or an alias of the symbol space. Here literal is a sequence of Unicode characters that must be an element in the lexical space of the symbol space symspace . For instance, "1.2"^^xsd:decimal and "1"^^xsd:decimal are legal symbols because 1.2 and 1 are members of the lexical space of the XML Schema data type xsd:decimal . On the other hand, "a+2"^^xsd:decimal is not a legal symbol, since a+2 is not part of the lexical space of xsd:decimal . The set of all symbol spaces that partition Const is considered to be part of the logic language of RIF-FLD.RIF requires that all dialects include the following symbol spaces.
Rule sets that are exchanged through RIF can use additional symbol
spaces.
|
The lexical spaces of the above symbol spaces are defined in the
above symbol spaces are defined in thedocument [XML-SCHEMA2].
These two symbol spaces represent two subtypes of the XML Schema datatype xsd:duration with well-defined value spaces, since xsd:duration does not have a well-defined value space (this may be corrected in later revisions of XML Schema datatypes, in which case the revised datatype would be suitable for RIF DTB). The lexical spaces of the above symbol spaces are defined in the document [XDM].
This symbol space represents XML content. The lexical space of rdf:XMLLiteral is defined in the document [RDF-CONCEPTS].
This symbol space represents text strings with a language tag attached. The lexical space of rif:text is the set of all Unicode strings of the form ...@LANG, i.e., strings that end with @LANG where LANG is a language identifier as defined in [RFC-3066].
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.
Constant symbols that belong to this symbol space are intended to be used in a way similar to RDF resources [RDF-SCHEMA]. The lexical space consists of all absolute IRIs as specified in [RFC-3987]; it is unrelated to the XML primitive type anyURI. A rif:iri constant must be interpreted as a reference to one and the same object regardless of the context in which that constant occurs.
Symbols in this symbol space are local to the RIF documents in
which they occur. This means that occurrences of the same
rif:local constant in different documents are viewed as
unrelated distinct constants, but occurrences of the same
rif:local constant in the same document must refer to the
same object. The lexical space of rif:local is the same asa subspace
of the lexical space of xsd:string. 2.2 Data Types Data types in RIFNamely, we allow
unicode strings which are also valid XML NCNames
as defined in [XML-NS].
which have special semantics."literal"^^<identifier>
ANGLEBRACKIRI ::= '<' IRI_REF '>' STRING ::= '"' UNICODESTRING '"' CURIE ::= PNAME_LN | PNAME_NS Const ::= STRING '^^'ANGLEBRACKIRI | STRING '^^' CURIE | ANGLEBRACKIRI → shortcut forshort)isasymbolspacethathasanassociatedset,calledrif:iri | CURIE → shortcut for rif:iri | STRING → shortcut for xsd:string | NumericLiteral → shortcut for xsd:integer,xsd:decimal,xsd:double | '_' LocalName → shortcut for rif:local
This relies on reuse of the value spacefollowing grammar productions
defined in other documents:
PNAME_LN, cf. http://www.w3.org/TR/rdf-sparql-query/#rPNAME_LN
PNAME_NS, cf. http://www.w3.org/TR/rdf-sparql-query/#rPNAME_NS
LANGTAG, cf. http://www.w3.org/TR/rdf-sparql-query/#rLANGTAG
NumericLiteral, cf. http://www.w3.org/TR/rdf-sparql-query/#rNumericLiteral
IRI_REF, cf. http://www.w3.org/TR/rdf-sparql-query/#rIRI_REF
LocalName, cf. http://www.w3.org/TR/2006/REC-xml-names11-20060816/#NT-LocalPart
UNICODESTRING, any unicode string where quotes are
escaped and a mapping fromadditionally all the other escpape sequences defined in
http://www.w3.org/TR/rdf-sparql-query/#grammarEscapes
and http://www.w3.org/TR/rdf-sparql-query/#codepointEscape.
In this grammar, CURIE stands for compact IRIs [CURIE]. For instance, "1.2"^^xsd:decimal and "1"^^xsd:decimal are legal symbols because 1.2 and 1 are members of the lexical space of the XML Schema data type xsd:decimal. On the other hand, "a+2"^^xsd:decimal is not a legal symbol, since a+2 is not part of the lexical space of xsd:decimal.
Data types 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 data type). A primitive data type (or just a data type, for short) is a symbol space that has
Semantic structures are always defined with respect to a particular set of data types, denoted by DTS. In a concrete dialect, DTS always includes the data types supported by that dialect. All RIF dialects must support the following primitive data types:
Their value spaces and the lexical-to-value-space mappings are defined as follows:
The value space and the lexical-to-value-space mapping for rif:text defined here are compatible with RDF's semantics for strings with named tags [RDF-SEMANTICS].
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).
Syntactically,In RIF's presentation syntax built-in predicates and functions
in RIFare syntactically represented as external terms of the form:
'External' '(' Expr ')'
where Expr is a positional term as defined in in RIF Framework for Logic Dialects (see also in RIF Basic Logic Dialect). For RIF's normative syntax, see XML Serialization Syntax for RIF-BLD.
RIF-FLD introduces the notion of an external schema to describe both the well-formed externally defined terms and their semantics. In the special case of a RIF built-in, external schemas have especially simple form. A built-in named f that takes n arguments has the schema
(?X( ?X1 ... ?X... ?Xn;
f(?X1 ... ?X... ?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.
The semantics of external terms in RIF-FLD and RIF-BLD is defined using two mappings: Iexternal and Itruth ο Iexternal.
If σ represents a built-in function, Iexternal(σ) must be that function.
For each built-in function with external schema σ, the present document specifies the mapping Iexternal(σ).
In RIF logical semantics, this mapping is used to assign truth values to formulas. In the special case of RIF built-ins, it is used to assign truth values to RIF built-in predicates. The built-in predicates can have the truth values t or f only.
For a built-in predicate with schema σ, RIF-FLD and RIF-BLD require that the truth-valued mapping Itruth ο Iexternal(σ) must agree with the specification of the corresponding built-in predicate.
For each RIF built-in predicate with schema σ, the present document specifies Itruth ο Iexternal(σ).
This section defines the syntax and semantics of all built-in predicates and functions in RIF. For each built-in, the following is defined:
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.
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.
Typically, built-in functions and predicates are defined over the value spaces of appropriate data types. 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 for different semantic structures, the value of Iexternal(σ)(a1 ... an) can be anything if one of the arguments is not in its intended domain. Similarly, Itruth ο Iexternal(σ)(a1 ... an) can be t in some interpretations and f in others.
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 data type guards.
Many built-in functions and predicates described below are adapted
from XQuery 1.0 and XPath 2.0 Functions and Operators[XPath-Functions]
and, when appropriate, we will refer to the definitions in that
specification in order to avoid copying them.
RIF requires guard predicates for all its supported datatypes.
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#ispred:isDATATYPE
"^^rif:iri ( ?arg( ?arg1 ) )
Guard predicates do not depend on a specific intended domain.
Itruth ο
Iexternal( ?arg1;
"http://www.w3.org/2007/rif-builtin-predicates#ispred:isDATATYPE "^^rif:iri( ?arg1 ) )(s1) =
t if and only if s1 is in the value space of
DATATYPE and f otherwise.
Accordingly, the following schemas are defined:
( ?arg( ?arg1;
"http://www.w3.org/2007/rif-builtin-predicates#isLong"^^rif:iri ( ?argpred:isInteger( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isInteger"^^rif:iri( ?argpred:isDecimal
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDecimal"^^rif:iri ( ?argpred:isDouble
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isString"^^rif:iri ( ?argpred:isString
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isTime^^rif:iri ( ?argpred:isTime ( ?arg1
) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isDateTime"^^rif:iri ( ?argpred:isDateTime
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isXMLLiteral"^^rif:iri ( ?argpred:isDayTimeDuration
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isText"^^rif:iri ( ?argpred:isYearMonthDuration
( ?arg1 ) )
Likewise, RIF has negative guards for all its supported datatypes. These built-in predicates have the schema ( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNot DATATYPE "^^rif:iri ( ?argpred:isXMLLiteral
( ?arg1 ) )
with I external( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNot DATATYPE "^^rif:iripred:isText ( ?arg1
) )
Likewise, RIF has negative guards for all its supported datatypes.
( ?arg1; pred:isNotDATATYPE ( ?arg1 ) )
Negative guard predicates do not depend on a specific intended domain.
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:
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotLong"^^rif:iri ( ?argpred:isNotInteger
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotInteger"^^rif:iri ( ?argpred:isNotDecimal
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDecimal"^^rif:iri ( ?argpred:isNotDouble
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotString"^^rif:iri ( ?argpred:isNotString
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotTime"^^rif:iri ( ?argpred:isNotTime
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotDateTime"^^rif:iri ( ?argpred:isNotDateTime
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotXMLLiteral"^^rif:iri ( ?argpred:isNotDayTimeDuration
( ?arg1 ) )
( ?arg( ?arg1; "http://www.w3.org/2007/rif-builtin-predicates#isNotText"^^rif:iri ( ?argpred:isNotYearMonthDuration
( ?arg1 ) )
( ?arg1; pred:isNotXMLLiteral ( ?arg1 ) )
( ?arg1; pred:isNotText ( ?arg1 ) )
Future dialects may extend this list of guards to other datatypes, but RIF does not require guards for all datatypes.
RIF requires cast functions for all its supported datatypes,
i.e. ( ?argfor each datatype DATATYPE there is an external
function as follows:
( ?arg1; "DATATYPE
"^^rif:iri ( ?arg( ?arg1 ) )
The value spaces of datatypes castable to DATATYPE
according to the primitive data types definedtable in
Section []17.1 of [XPath-Functions].
Iexternal( ?arg1;
"DATATYPE "^^rif:iri( ?arg1 ) )(s1) =
s1' such that s1' is the conversion of
s1 to the value space of xsd:DATATYPE if and only if conversion from s 1 is possibleaccording
to the table in
Section 17.1 of XQuery 1.0 and XPath 2.0 Functions and Operators , and err:XPTY0004 otherwise. Partial conversion functions between the datatypes xsd:time , xsd:string , xsd:dateTime[XPath-Functions]. Note that these conversions are only
partial.
If an argument value is outside of the intended domain or
outside the partial conversions defined asin [XPath-Functions], the conversion table in Section 17.1value of
XQuery 1.0 and XPath 2.0 Functionsthe function is left unspecified and Operators .can vary from one semantic
structure to another.
Note that neither the threeremaining data types xsd:long , rif:XMLLiteral ,types, i.e. the subtypes of
xsd:integer and err:rif:XMLLiteral, nor the symblsymbol
space rif:iri do notappear in that table, butthe following considerationsconversion table of
[XPath-Functions], but
the following considerations apply:
Editor's note: Although rif:iri is not a datatype, I
left conversions from and to |
4.3.1The following functions and predicates are adapted from the
respective numeric functions and operators in [XPath-Functions].
(?arg1 ?arg2; func:numeric-add(?arg1 ?arg2))
The value spaces of xsd:integer, xsd:longxsd:double,
or xsd:decimal for both arguments.
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 XQuery 1.0 and XPath 2.0 Functions and Operators .[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 are defined accordingly with respect to their corresponding operators in [XPath-Functions] and we will only add further explanations where needed.
(?arg1 ?arg ?arg2;
func:numeric-subtract( ?argfunc:numeric-subtract( ?arg1 ?arg ?arg2)
)
(?arg1 ?arg ?arg2;
func:numeric-multiply( ?argfunc:numeric-multiply( ?arg1 ?arg ?arg2)
)
(?arg1 ?arg2;
pred:numeric-equal(?argfunc:numeric-divide( ?arg1 ?arg2 )))
)
The value spaces of xsd:integer, xsd:longxsd:double,
or xsd:decimal for both arguments. Mapping: When both s 1 and s 2 belong to their intended domains, External(pred:numeric-equal(s 1 s 2 )) is t ifthe first argument and
only if op:numeric-equal (s 1xsd:integer, s 2 ) returns truexsd:double, as defined in XQuery 1.0or xsd:decimal
without zero for the second argument.
This function backs up the "idiv" operator and XPath 2.0 Functionsperforms an
integer division: that is, it divides the first argument by the
second, and Operators .returns the integer obtained by truncating the
fractional part of the result. 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
truthvalue of the function is left unspecified and can vary from one
semantic structure to another. 2. op:numeric-less-than (?arg 1 ?arg 2 ; pred:numeric-less-than( ?arg 1 ?arg 2 ) ) 3. op:numeric-greater-thananother, which here particularly means that
RIF does not prescribe the behavior on division by zero.
(?arg1 ?arg ?arg2;
pred:numeric-greater-than( ?argfunc:numeric-integer-divide( ?arg1 ?arg ?arg2)
)
The following, we often encounter several versionsvalue spaces of some built-ins. Since XPathxsd:integer, xsd:double,
or xsd:decimal for the first argument and
Xquery allow overloading, i.e.xsd:integer, xsd:double, or xsd:decimal
without zero for the samesecond argument.
This function orbacks up the "idiv" operator name occurring with different arities. We suggest to treat this likewise in RIF,and performs an
integer division: that is, it divides the first argument by numberingthe
different versionssecond, and returns the integer obtained by truncating the
fractional part of the respective built-ins and treatingresult.
If an argument value is outside of the unnumbered version as syntactic sugar, i.e. for instance insteadintended domain, the
value of External( func:concat2( str 1 , str 2 ) )the function is left unspecified and </tt>External( func:concat3( str 1 str 2 str 3 ) )</tt> we equally allow simplycan vary from one
semantic structure to write External( func:concat( str 1 , str 2 ) ) and </tt>External( func:concat( str 1 str 2 str 3 ) )</tt>. Noteanother, which here particularly means that
this is really purely syntactic sugar, andRIF does not mean that for external predicates and functions we lift restriction that each function and predicate has a unique assigned arity. Those schemata for which we allow this syntactic sugar, appear inprescribe the same box. 4.4.1 Functionsbehavior on Strings 1. fn:compare ( ?comparand 1 ?comparand 2 ; func:compare1(?comparand 1 ?comparand 2 ) ) ( ?comparand 1 $comparand 2 $collation; func:compare2(?comparand 1 ?comparand 2 ?collation) ) where I external ( ( ?comparanddivision by zero.
(?arg1 ?comparand ?arg2;
func:compare1(?comparandfunc:numeric-mod( ?arg1 ?comparand ?arg2)
)(s 1 s 2)
The value spaces of the s 1 is respectively less than, equal to,xsd:integer, xsd:double,
or greater thanxsd:decimal for the first argument and
xsd:integer, xsd:double, or xsd:decimal
without zero for the second argument.
Backs up the "mod" operator.
If an argument value is outside of s 2 , according tothe rulesintended domain, the
value of the collationfunction 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
used. 2. fn:concat ( ?argzero.
(?arg1 ?arg2;
func:concat1( 1 ) ) ( ?argpred:numeric-equal(?arg1 ?arg ?arg2 ; func:concat2(?arg))
The value spaces of xsd:integer, xsd:double, or xsd:decimal for both arguments.
When both s1 ?argand s2
) ) ... ( ?argbelong to their intended domains,
External(pred:numeric-equal(s1 ?args2 ... ?arg n ; func:concat n (?arg))
is t if and only if op:numeric-equal(s1 ?arg,
s2 ... ?arg n) ) Accepts xs:anyAtomicType arguments and casts them to xsd:string.returns the xsd:string thattrue, as defined in [XPath-Functions].
If an argument value is the concatenationoutside of the valuesintended domain, the
truth value of its arguments after conversion. Only defined if all arguments are castablethe function is left unspecified and can vary from
one semantic structure to strings (see Section on Cast functions above), otherwise returns an error asanother.
The following numeric built-in predicates are defined for fn:concat .acordingly
with respect to their corresponding operators in [XPath-Functions].
2. fn:string-join ( ?argop:numeric-less-than
(?arg1 ?arg ?arg2;
func:string-join2(?argpred:numeric-less-than( ?arg1 ?arg ?arg2)
)
( ?arg3. op:numeric-greater-than
(?arg1 ?arg ?arg2 ?arg 3;
func:string-join2(?argpred:numeric-greater-than( ?arg1 ?arg ?arg2 ?arg 3)
)
... ( ?arg4. pred:numeric-less-than-or-equal
(?arg1 ?arg ?arg2 ... ?arg n;
func:string-join n (?argpred:numeric-less-than-or-equal( ?arg1 ?arg ?arg2 ... ?arg n)
)
Returns a xsd:string created by concatenating the arguments5. pred:numeric-greater-than-or-equal
(?arg1 to ( n -1) using the n th argument as a separator. Only defined if all arguments are strings, otherwise returns an error as defined for fn:string-join . 3. fn:substring ( ?sourceString� ?startingLoc; fn:substring1( ?sourceString� ?startingLoc) ?arg2;
pred:numeric-greater-than-or-equal( ?arg1 ?arg2)
( fn:substring2( ?sourceString ?startingLoc ?length))
The position indicated byfollowing functions and predicates are adapted from the
value of ?startingLocrespective functions and continuing foroperators on strings in [XPath-Functions].
Editor's note: The |
In the characters returned do not extend beyond ?sourceString. If ?startingLoc is zerofollowing, we encounter several versions of some
built-ins with varying arity, since XPath and XQuery allow
overloading, i.e. the same function or negative, only those charactersoperator name occurring with
different arities. We treat this likewise in positions greater than zero are returned. 4. fn:string-length ( func:string-length1() ) ( ?arg ; func:string-length2( ?arg ) ) Returns an xsd:integer equal toRIF, by numbering the
length in charactersdifferent versions of the argument if it is a xsd:string. 5. fn:upper-case ( ?arg ; func:upper-case( ?argrespective built-ins and treating the
unnumbered version as syntactic sugar, i.e. for instance instead of
External( func:concat2( str1, str2)
) 6. fn:lower-case ( ?arg ; func:lower-case( ?argand External( func:concat3( str1
str2 str3 ) ) 7. fn:encode-for-uri ( ?arg ; func:encode-for-uri( ?argwe equally allow simply to
write External( func:concat( str1, str2)
) This function encodes reserved characters in an xs:stringand External( func:concat( str1
str2 str3 ) ). Note that this is intended to be used in the path segment of a URI. It is invertible butreally
purely syntactic sugar, and does not idempotent. 8. fn:iri-to-uri ( ?iri ; func:iri-to-uri ( ?iri ) ) 9. fn:escape-html-uri ( ?uri ;func:escape-html-uri( ?uri ) ) This function escapes all characters except printable characters of the US-ASCII coded character set, specifically the octets ranging from 32 to 126 (decimal). The effect ofmean that for external
predicates and functions we lift the function is to escape a URIrestriction made in the manner html user agents handle attribute valuesBLD 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,function and then representing each of these octets in the form %HH, where HH is the hexadecimal representation of the octet.predicate has a unique assigned arity. Those
schemata for which we allow this function must always generate hexadecimal values usingsyntactic sugar, appear in the
upper-case letters A-F. 10. fn:substring-before ( ?argsame box.
1. fn:compare
( ?comparand1 ?arg ?comparand2;
func:substring-before1( ?argfunc:compare1(?comparand1 ?arg ?comparand2)
)
( ?arg( ?comparand1 ?arg$comparand2
?collation; func:substring-before2( ?arg$collation;
func:compare2(?comparand1 ?arg ?comparand2 ?collation ?collation)
)
The value space of xsd:string for all arguments.
Iexternal(
?arg( ?comparand1 ?arg ?comparand2;
func:substring-after1( ?argfunc:compare1(?comparand1 ?arg ?comparand2)
) ( ?arg 1 ?arg 2 ?collation; func:substring-after2( ?arg)(s1 ?args2 ?collation ) ) 12. fn:replace ( ?input ?pattern ?replacement; func:replace1( ?input ?pattern ?replacement ) ) ( ?input ?pattern ?replacement ?flags; func:replace2( ?input ?pattern ?replacement ?flags )) Editor's note: I removed fn:tokenize from previous versions, since tokenizer returns a sequence of strings, we might reconsider this if we (re-)introduce lists, but I left this out for the moment. 4.4.2 Predicates= res such that res =
-1, 0, or 1, depending on Stringswhether the predicates described here examinevalue of the first string argument to see whether it contains the second string argument as a substring. 1. fn:contains ( ?arg 1 ?arg 2 ; pred:contains1( ?arg 1 ?arg 2 ) ) ( ?arg 1 ?arg 2 ?collation ; pred:contains2( ?args1 ?arg 2 ?collation ) ) Returns true or false indicating whetheris
respectively less than, equal to, or notgreater than the value of
$arg1 contains (at the beginning, ats2, according to the end, or anywhere within) at least one sequencerules of the collation
unitsthat provides a minimal match tois used.
If an argument value is outside of the collation units inintended domain, the
value of $arg2, according tothe collation that is used. "Minimal match"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 Unicode Collation Algorithm . Shall[XPath-Functions] and we return an error or false on typing errors?only
give informal descriptions of the respective mappings
Iexternal.
2. fn:starts-with ( ?argfn:concat
( ?arg1 ?arg 2; pred:starts-with1( ?argfunc:concat1(1 ?arg 2)
( ?arg 1 ?arg 2 ?collation; pred:starts-with2( ?arg 1 ?arg 2 ?collation) Shall we return an error or false on typing errors? 3. fn:ends-with (?arg)
( ?arg1 ?arg ?arg2;
fn:ends-with1( ?argfunc:concat2(?arg1 ?arg ?arg2 ) )
(?arg...
( ?arg1 ?arg ?arg2
?collation; fn:ends-with2( ?arg... ?argn;
func:concatn(?arg1 ?arg ?arg2
?collation) ) Shall we return an error or false on typing errors? 4. fn:matches ( ?input ?pattern; pred:matches1( ?input ?pattern) ) ( ?input ?pattern ?flags; pred:matches2( ?input ?pattern ?flags... ?argn ) )
Following the function returns true if the input matches the regular expression supplied as pattern as influenced by the flags, if present; otherwise, it returns false. The effect of calling the first versiondefinition of fn:concat
this function (omittingaccepts xs:anyAtomicType arguments and casts them to
xsd:string. Thus, the flags)intended domain for all arguments is
the same as the effectunion of calling the second version with the flags argument setall value spaces castable to a zero-length string. Shall we return an error or false on typing errors? 4.5 Functions and Predicates on Dates and Times If not stated otherwise, in the following we define schemas for functions and operators defined on the date and time datatypes in XML Schema Part 2: Datatypes Second Edition .String
xsd:string as defined in Section 3.3.2 Dates and Times , xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth, xsd:gYear, xsd:gMonthDay, xsd:gMonth, xsd:gDay values, referred to collectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, secondCast functions
for Datatypes and timezone. The value of the first five components are xsd:integers. The value ofrif:iri above.
Returns the second componentxsd:string that is an xsd:decimal andthe valueconcatenation of the
timezone component isvalues of its arguments after conversion.
If an xsd:dayTimeDuration. For all the date/time datatypes, the timezone propertyargument value is optional and may or may not be present. Depending on the datatype, someoutside of the remaining six properties must be present and some must be absent. Absent, or missing, properties are represented by the empty sequence. This value is referred to asintended domain, the
localvalue in thatof the valuefunction is in the given timezone. Before comparing or subtracting xsd:dateTime values, this local value must be translated or normalized to UTC. 4.5.1 Predicates on Dateleft unspecified and Time Values 1. op:dateTime-equal ( ?argcan vary from one
semantic structure to another.
( ?arg1 ?arg ?arg2;
pred:dateTime-equal( ?argfunc:string-join2(?arg1 ?arg ?arg2 )
)
where I external( ?arg1 ?arg2 ?arg3;
pred:dateTime-equal( ?argfunc:string-join2(?arg1 ?arg2 ?arg3
) )(s)
...
( ?arg1 s ?arg2
) = t if... ?argn;
func:string-joinn(?arg1 ?arg2
... ?argn ) )
The value space of xsd:string for all arguments.
Returns a xsd: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.
4. fn:substring
( ?sourceString ?startingLoc; func:substring1( ?sourceString ?startingLoc) )
( ?sourceString ?startingLoc ?length ; func:substring2( ?sourceString ?startingLoc ?length) )
The value space of xsd:string for ?sourceString and the union of the value spaces of xsd:integer, xsd:long, or xsd:decimal for the remaining two arguments.
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.
( func:string-length1() )
( ?arg ; func:string-length2( ?arg ) )
The value space of xsd:string for ?arg.
Returns an xsd:integer equal to the length in characters of the argument if it is a xsd:string.
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.
( ?arg ; func:upper-case( ?arg ) )
The value space of xsd:string for ?arg.
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.
( ?arg ; func:lower-case( ?arg ) )
The value space of xsd:string for ?arg.
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.
( ?arg ; func:encode-for-uri( ?arg ) )
The value space of xsd:string for ?arg.
This function encodes reserved characters in an xsd: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.
( ?iri ; func:iri-to-uri ( ?iri ) )
The value space of xsd:string for ?iri.
This function converts an xsd: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.
( ?uri ;func:escape-html-uri( ?uri ) )
The value space of xsd:string for ?uri.
This function escapes all characters except printable characters of the US-ASCII coded character set, specifically the octets ranging from 32 to 126 (decimal). The effect of the function is to escape a URI in the manner html user agents handle attribute values that expect URIs. Each character in $uri to be escaped is replaced by an escape sequence, which is formed by encoding the character as a sequence of octets in UTF-8, and then representing each of these octets in the form %HH, where HH is the hexadecimal representation of the octet. This function must always generate hexadecimal values using the upper-case letters A-F.
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.
( ?arg1 ?arg2; func:substring-before1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation; func:substring-before2( ?arg1 ?arg2 ?collation ) )
The value space of xsd:string for all arguments.
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.
( ?arg1 ?arg2; func:substring-after1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation; func:substring-after2( ?arg1 ?arg2 ?collation ) )
The value space of xsd:string for all arguments.
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.
13. fn:replace
( ?input ?pattern ?replacement; func:replace1( ?input ?pattern ?replacement ) )
( ?input ?pattern ?replacement ?flags; func:replace2( ?input ?pattern ?replacement ?flags ) )
The value space of xsd:string for all arguments.
The function returns the xsd: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.
1. fn:contains
( ?arg1 ?arg2; pred:contains1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation ; pred:contains2( ?arg1 ?arg2 ?collation ) )
The value space of xsd:string for all arguments.
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.
( ?arg1 ?arg2; pred:starts-with1( ?arg1 ?arg2 )
( ?arg1 ?arg2 ?collation; pred:starts-with2( ?arg1 ?arg2 ?collation)
The value space of xsd:string for all arguments.
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. fn:ends-with
(?arg1 ?arg2; fn:ends-with1( ?arg1 ?arg2 ) )
(?arg1 ?arg2 ?collation; fn:ends-with2( ?arg1 ?arg2 ?collation) )
The value space of xsd:string for all arguments.
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.
4. fn:matches
( ?input ?pattern; pred:matches1( ?input ?pattern) )
( ?input ?pattern ?flags; pred:matches2( ?input ?pattern ?flags ) )
The value space of xsd:string for all arguments.
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.
If not stated otherwise, in the following we define schemas for functions and operators defined on the date and time datatypes in [XPath-Functions].
As defined in Section 3.3.2 Dates and Times, xsd:dateTime, xsd:date, xsd:time, xsd:gYearMonth, xsd:gYear, xsd:gMonthDay, xsd:gMonth, xsd:gDay values, referred to collectively as date/time values, are represented as seven components or properties: year, month, day, hour, minute, second and timezone. The value of the first five components are xsd:integers. The value of the second component is an xsd:decimal and the value of the timezone component is an xsd:dayTimeDuration. For all the date/time datatypes, the timezone property is optional and may or may not be present. Depending on the datatype, some of the remaining six properties must be present and some must be absent. Absent, or missing, properties are represented by the empty sequence. This value is referred to as the local value in that the value is in the given timezone. Before comparing or subtracting xsd:dateTime values, this local value must be translated or normalized to UTC.
( ?arg ; func:year-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Iexternal( ?arg ; func-year-from-dateTime( ?arg ) )(s) = res
such that res is the result of fn:year-from-dateTime(s) 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.
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 Iexternal.
( ?arg ; func:month-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Returns an xsd:integer between 1 and 12, both inclusive, representing the month 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 vary from one semantic structure to another.
( ?arg ; func:day-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Returns an xsd:integer between 1 and 31, both inclusive, representing the day 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 vary from one semantic structure to another.
( ?arg ; func:hours-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Returns an xsd: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 vary from one semantic structure to another.
( ?arg ; func:minutes-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Returns an xsd:integer between 0 and 59, both inclusive, representing the minutes 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 vary from one semantic structure to another.
( ?arg ; func:seconds-from-dateTime( ?arg ) )
The value space of xsd:dateTime for ?arg.
Returns an xsd: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.
( ?arg ; func:year-from-date( ?arg ) )
The value space of xsd:date for ?arg.
Returns an xsd:integer representing the year in the localized value of ?arg. The value may be negative.
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.
( ?arg ; func:month-from-date( ?arg ) )
The value space of xsd:date for ?arg.
Returns an xsd:integer between 1 and 12, both inclusive, representing the month 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 vary from one semantic structure to another.
( ?arg ; func:day-from-date( ?arg ) )
The value space of xsd:date for ?arg.
Returns an xsd:integer between 1 and 31, both inclusive, representing the day 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 vary from one semantic structure to another.
( ?arg ; func:hours-from-time( ?arg ) )
The value space of xsd:time for ?arg.
Returns an xsd: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 vary from one semantic structure to another.
( ?arg ; func:minutes-from-time( ?arg ) )
The value space of xsd:time for ?arg.
Returns an xsd:integer between 0 and 59, both inclusive, representing the minutes 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 vary from one semantic structure to another.
( ?arg ; func:seconds-from-time( ?arg ) )
The value space of xsd:time for ?arg.
Returns an xsd: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.
( ?arg ; func:years-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:yearMonthDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:integer representing the years component in the value of ?arg. The result is obtained by casting ?arg to an xsd: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 vary from one semantic structure to another.
( ?arg ; func:months-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:yearMonthDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:integer representing the months component in the value of ?arg. The result is obtained by casting ?arg to an xsd: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.
( ?arg ; func:days-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:integer representing the days component in the value of ?arg. The result is obtained by casting ?arg to an xsd: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.
( ?arg ; func:hours-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:integer representing the hours component in the value of ?arg. The result is obtained by casting ?arg to an xsd: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.
( ?arg ; func:minutes-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:integer representing the minutes component in the value of ?arg. The result is obtained by casting ?arg to an xsd: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.
( ?arg ; func:seconds-from-duration( ?arg ) )
The union of the value spaces of datatypes castable to xsd:dayTimeDuration according to the table in Section 17.1 of [XPath-Functions].
Returns an xsd:decimal representing the seconds
component in the value of ?arg. The result is obtained by
casting ?arg to an xsd:dayTimeDuration and onlythen
computing the seconds component.
If op:dateTime-equal (s 1 , s 2the 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.
( ?arg ; func:timezone-from-dateTime( ?arg ) )
The value space of xsd:dateTime.
Returns true , as defined in XQuery 1.0 and XPath 2.0 Functionsthe timezone component of ?arg if any. If $arg has
a timezone component, then the result is an
xsd:dayTimeDuration that indicates deviation from UTC; its
value may range from +14:00 to -14:00 hours, both inclusive.
If the argument value is outside of the intended domain, the
value of the function is left unspecified and Operators , f otherwise.can vary from one
semantic structure to another.
The following schematatwo functions are defined analogously with respect to their corresponding operators as defined in XQuery 1.0 and XPath 2.0 Functionsfor intended
domains xsd:date and Operatorsxsd:time
( ?arg ; func:timezone-from-date( ?arg ) )
( ?arg ; func:timezone-from-time( ?arg ) )
( ?arg ; func:add-yearMonthDurations( ?arg ) )
Adds two xsd:yearMonthDurations. Returns an xsd:yearMonthDuration.
2. op:dateTime-less-than ( ?arg 1 ?arg 2 ; pred:dateTime-less-than(?arg 1 ?arg 222.
op:subtract-yearMonthDurations
( ?arg ; func:subtract-yearMonthDurations( ?arg ) )
3. op:dateTime-greater-than ( ?arg 1 ?arg 2 ; pred:dateTime-greater-than(?arg 1 ?arg 2Subtracts one xsd:yearMonthDuration from another.
Returns an xs:yearMonthDuration.
23. op:multiply-yearMonthDuration
( ?arg ; func:multiply-yearMonthDuration( ?arg ) )
4. op:date-equal ( ?arg 1 ?arg 2 ; pred:date-equal( ?arg 1 ?arg 2Multiplies an xsd:yearMonthDuration by an
xsd:double. Returns an xsd:yearMonthDuration.
24. op:divide-yearMonthDuration
( ?arg ; func:divide-yearMonthDuration( ?arg ) )
Divides an xsd:yearMonthDuration by an xsd:double. Returns an xsd:yearMonthDuration.
25. op:divide-yearMonthDuration-by-yearMonthDuration
( ?arg ; func:divide-yearMonthDuration-by-yearMonthDuration( ?arg ) )
Divides an xsd:yearMonthDuration by an xsd:yearMonthDuration. Returns an xsd:decimal.
( ?arg ; func:add-dayTimeDurations( ?arg ) )
Adds two xsd:dayTimeDurations. Returns an xsd:dayTimeDuration.
27. op:subtract-dayTimeDurations
( ?arg ; func:subtract-dayTimeDurations( ?arg ) )
Subtracts one xsd:dayTimeDuration from another. Returns an xsd:dayTimeDuration.
28. op:multiply-dayTimeDuration
( ?arg ; func:multiply-dayTimeDuration( ?arg ) )
Multiplies an xsd:dayTimeDuration by a xsd:double. Returns an xsd:dayTimeDuration.
( ?arg ; func:divide-dayTimeDuration( ?arg ) )
5. op:date-less-than ( ?arg 1 ?arg 2 ; pred:date-less-than(?arg 1 ?arg 2Divides an xsd:dayTimeDuration by an
xsd:double. Returns an xsd:dayTimeDuration.
30. op:divide-dayTimeDuration-by-dayTimeDuration
( ?arg ; func:divide-dayTimeDuration-by-dayTimeDuration( ?arg ) )
6. op:date-greater-than ( ?argDivides an xsd:dayTimeDuration by an
xsd:dayTimeDuration. Returns an xsd:decimal.
( ?arg1 ?arg ?arg2;
pred:date-greater-than(?argpred:dateTime-equal( ?arg1 ?arg ?arg2)
)
The value space of xsd:dateTime for both arguments.
where Itruth ο
Iexternal( ?arg1 ?arg ?arg2;
pred:time-equal( ?argpred:dateTime-equal( ?arg1 ?arg ?arg2 )
) 8. op:time-less-than ( ?arg 1 ?arg 2 ; pred:time-less-than(?arg)(s1 ?args2) ) 9. op:time-greater-than ( ?arg 1 ?arg 2 ; pred:time-greater-than(?arg= t
if and only if op:dateTime-equal(s1 ?arg,
s2) ) 4.5.2 Functions on Dates and Times 1. fn:year-from-dateTime ( ?arg ; func:year-from-dateTime( ?arg ) ) where I external ( ?arg ; func:year-from-dateTime( ?arg ) )(s) = res such that res is the result of fn:year-from-dateTime (s)returns true, as defined in XQuery 1.0 and XPath 2.0 Functions and Operators[XPath-Functions], f in
case false is returned.
If san argument value is inoutside of the intended domain, the
truth value spaceof xsd:dateTime, otherwise returns an error as defined in XQuery 1.0 and XPath 2.0 Functionsthe function is left unspecified and Operators .can vary from
one semantic structure to another.
The following schemata for comparison operators are defined
analogously with respect to their corresponding functions and possible error codesoperators as
defined in XQuery 1.0 and XPath 2.0 Functions and Operators . Editor's remark: Where in XQuery 1.0 and XPath 2.0 Functions and Operators are the errors for these functions defined? We slightly deviate here from the original definition of fn:year-from-dateTime which says: "If ?arg is the empty sequence, returns the empty sequence." We have no terminology of "sequence". Editor's remark: I am not sure whether this[XPath-Functions], where the intended domain for both
arguments is a problem. Doimplicit by the operator name and we have to deal with empty sequences?only give
additional details on intended domains and mapping as needed.
2. fn:month-from-dateTime ( ?argop:dateTime-less-than
( ?arg1 ?arg2;
func:month-from-dateTime( ?argpred:dateTime-less-than(?arg1 ?arg2 )
)
3. fn:day-from-dateTime ( ?argop:dateTime-greater-than
( ?arg1 ?arg2;
func:day-from-dateTime( ?argpred:dateTime-greater-than(?arg1 ?arg2 )
)
4. fn:hours-from-dateTime ( ?argop:date-equal
( ?arg1 ?arg2;
func:hours-from-dateTime( ?argpred:date-equal( ?arg1 ?arg2)
)
5. fn:minutes-from-dateTime ( ?argop:date-less-than
( ?arg1 ?arg2;
func:minutes-from-dateTime( ?argpred:date-less-than(?arg1 ?arg2 )
)
6. fn:seconds-from-dateTime ( ?argop:date-greater-than
( ?arg1 ?arg2;
func:seconds-from-dateTime( ?argpred:date-greater-than(?arg1 ?arg2 )
)
7. fn:year-from-date ( ?argop:time-equal
( ?arg1 ?arg2;
func:year-from-date( ?argpred:time-equal( ?arg1 ?arg2)
)
8. fn:month-from-date ( ?argop:time-less-than
( ?arg1 ?arg2;
func:month-from-date( ?argpred:time-less-than(?arg1 ?arg2 )
)
9. fn:day-from-date ( ?argop:time-greater-than
( ?arg1 ?arg2;
func:day-from-date( ?argpred:time-greater-than(?arg1 ?arg2 )
)
10. fn:hours-from-time ( ?argop:duration-equal
( ?arg1 ?arg2;
func:hours-from-time( ?argpred:duration-equal( ?arg1 ?arg2)
)
The union of the value spaces of xsd:dayTimeDuration and xsd:yearMonthDuration for both arguments.
11.
fn:minutes-from-time ( ?argop:dayTimeDuration-less-than
( ?arg1 ?arg2;
func:minutes-from-time( ?argpred:dayTimeDuration-less-than(?arg1 ?arg2
) )
12.
fn:seconds-from-time ( ?argop:dayTimeDuration-greater-than
( ?arg1 ?arg2;
func:seconds-from-time( ?argpred:dayTimeDuration-greater-than(?arg1 ?arg2
) )
4.6 Functions and Predicates on rif:XMLLiterals We support (though not impose) an XPath built-in function, applied to XMLLiterals as follows. (?xml ?xquery; func:evalXQuery( ?xml ?xquery)13.
op:yearMonthDuration-less-than
( ?arg1 ?arg2;
pred:yearMonthDuration-less-than(?arg1 ?arg2
) where I external (?xml ?xquery; func:evalXQuery( ?xml ?xquery) )(s)
14. op:yearMonthDuration-greater-than
( ?arg1 ?arg2; pred:yearMonthDuration-greater-than(?arg1 ?arg2 ) )
15. pred:dateTime-less-than-or-equal
(?arg1 ?arg2; pred:dateTime-less-than-or-equal( ?arg1 ?arg2) )
16. pred:dateTime-greater-than-or-equal
(?arg1 ?arg2; pred:dateTime-greater-than-or-equal( ?arg1 ?arg2) )
17. pred:date-less-than-or-equal
(?arg1 ?arg2; pred:date-less-than-or-equal( ?arg1 ?arg2) )
18. pred:date-greater-than-or-equal
(?arg1 s ?arg2;
pred:date-greater-than-or-equal( ?arg1 ?arg2)
= res such that, if s)
19. pred:time-less-than-or-equal
(?arg1 is in the value space of rdf:XMLLiteral and s ?arg2 is in the value space of xsd:string and s;
pred:time-less-than-or-equal( ?arg1 ?arg2 is a syntactically valid XQuery expression, then res is the result of the XQuery s)
)
20. pred:time-greater-than-or-equal
(?arg1 ?arg2 on the context item being the root node of the XML document represented by s;
pred:time-greater-than-or-equal( ?arg1 , and otherwise if ?arg2)
)
Editor's note: No |
(?arg ; func:lang( ?argThe following function serves to extract the language tag from
values in the rif:text value space.
(?arg ; func:lang( ?arg ) )
The value space of rif:text for ?arg.
Iexternal(?arg ; func:lang( ?arg ) )(s) = res such that res is the language tag string of s, if s is in the value space of rif:text and ""^^xsd:string otherwise.
This section is an edited copy of a section from RIF Framework for Logic Dialects. It is reproduced here for convenience of the reader of the RIF-BLD document who might not be familiar with 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
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 the same schema, 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"^^xsd:string->?Y]) or (?V; "pred:isTime"^^rif:iri(?V)), is that ?X["foo"^^xsd:string->?Y] or "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"^^xsd:string->"123"^^xsd:integer]) and External("pred:isTime"^^rif:iri("22:33:44"^^xsd: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 can be no term,
t, that is an instance of two distinct schemas.
☐
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 important to understand 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.