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 62 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,data types,
built-in functions and built-in predicates requiredexpected to be supported
by RIF dialects such as the RIF
Basic Logic Dialect. This list shall be viewed asEach dialect supporting a catalogue which dialects can use by referencing which datatypes and builtins must be supported by implementationssuperset or
subset of the primitive data types, built-in functions and built-in
predicates defined here shall specify these specific dialects.additions or
restrictions. Some of the datatypesdata types are adopted from [XML-SCHEMA2]. A large part of the
definitions of the listed functions and operators are adapted from
[XPath-Functions].
Throughout this document we use the following prefixes for compact IRIs [CURIE] used for symbol spaces or for IRI constants in RIF's presentation syntax:
In RIF documents in presentation syntax, these prefixes can be defined using respective prefix directives in the preamble of the RIF document at hand [BLD].
Each constant (that is, each non-keyword symbol) in RIF belongs to a particular symbol space. To refer to a constant in a particular RIF symbol space, we use the following presentation syntax:
"literal"^^< identifiersymbolSpaceIri>
where literal is called the lexical
part of the symbol, and identifiersymbolSpaceIri is
an (absolute or relative) IRI identifying the symbol
space.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. We often also use
abbreviated syntax for denoting IRIs such as symbol space
identifiers, i.e., for example the constant "http://www.example.org"^^<http://www.w3.org/2007/rif#iri>
can be abbreviated as "http://www.example.org"^^rif:iri
in RIF's presentation syntax. More details about this and other
shortcut notations are given below.
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. 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:stringxs:string"
instead of "symbol space identified by
xsd:stringxs:string").
RIF requires that all dialects include the following symbol spaces.
Rule sets that are exchanged through RIF can use additional symbol
spaces.
and all the symbol spaces that corresponds to the subtypes of xsd:decimal as specified in [ XML-SCHEMA2 ]. Editor's note: The group still discussed whether all subtypes of xsd:decimal shall be supported or whether a basic subset such as xsd:integer and xsd:long should be supported.The lexical spaces of the above symbol spaces are defined in the
document [XML-SCHEMA2].
These two symbol spaces represent two subtypes of the XML Schema
datatype xsd:durationdata type xs:duration with well-defined value spaces,
since xsd:durationxs:duration does not have a well-defined value space
(this may be corrected in later revisions of XML Schema datatypes,data types,
in which case the revised datatypedata type 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,data type, striving for a uniform
symbol space for such text strings with a language tag.
Constant symbols that belong toConstants in 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.
SymbolsConstants 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 a subspace ofthe same as
the lexical space of xsd:stringxs:string.
Namely, we allowNote that, by the associated lexical space, not all unicode
strings whichare alsosyntactically valid XML NCName s as definedlexical parts for all symbol
spaces. That is, for instance "1.2"^^xs:decimal and
"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 is not a syntactically valid
constant, since a+2 is not part of the lexical space of
xs:decimal.
"literal"^^<identifier>
in order to make the presentation syntax more readable. That is, RIF's presentation syntax for constants is defined by the following EBNF.ANGLEBRACKIRI ::='<'IRI_REF'>'STRING ::= '"' UNICODESTRING '"' CURIE ::= PNAME_LN | PNAME_NS Const ::= STRING '^^'ANGLEBRACKIRI | STRING '^^' CURIE | ANGLEBRACKIRI → shortcut for rif:iri | CURIE → shortcut for rif:iri | STRING → shortcut forxsd:stringxs:string | NumericLiteral → shortcut forxsd:integer,xsd:decimal,xsd:doublexs:integer,xs:decimal,xs:double | '_' LocalName → shortcut for rif:local
ThisThe EBNF grammar relies on reuse of nonterminals defined in the
following grammar productions defined infrom other documents:
In this grammar, CURIE stands for compact IRIs
[CURIE]. First, compact IRIs can
be used for instance, "1.2"^^xsd:decimal and "1"^^xsd:decimal are legal symbols because 1.2 and 1 are members of the lexicalabbreviating symbol space of the XML Schema data type xsd:decimal . On the other hand, "a+2"^^xsd:decimal is not a legal symbol, since a+2IRIs, for instance it is
not part of the lexical spaceallowed to write "http://www.example.org"^^rif:iri instead
of
xsd:decimal . 2.2 Data Types Data types in RIF are symbol spaces which have special semantics."http://www.example.org"^^<http://www.w3.org/2007/rif#iri>,
assuming that is, each datatyperif is characterized by a fixed lexical space, value space and lexical-to-value-mapping. Definition (Primitive data type). A primitive data type (or justa data type ,prefix defined for short) isthe IRI
http://www.w3.org/2007/rif#iri
in a respective prefix directive
Prefix( rif http://www.w3.org/2007/rif# )
in the preamble of the RIF document at hand [BLD].
Furthermore, there exist convenient shortcut notations for
constants in specific symbol space that has an associated set, calledspaces, namely for constants in the
value spacesymbol spaces rif:iri, xs:string,
xs:integer, xs:decimal, xs:double, and
a mapping fromrif:local:
Constants in the lexical space ofthe symbol space to the value space, called lexical-to-value-space mapping . ☐ Semantic structures are always defined with respect to a particular set of data types, denotedrif:iri can be
abbreviated in two ways, either by DTS .simply using an absolute or
relative IRI enclosed in angle brackets, or by simply writing a
concrete dialect, DTS always includescompact IRI. The data types supported bysymbol space identifier is dropped in both these
alternatives. That dialect. All RIF dialects must support the following primitive data types: xsd:long xsd:integer xsd:decimal xsd:string xsd:time xsd:dateTime xsd:dayTimeDuration xsd:yearMonthDuration rdf:XMLLiteral rif:text Their value spaces and the lexical-to-value-space mappings are defined as follows:is, for instance
<http://www.example.org/xyz> is a valid abbreviation
for "http://www.example.org/xyz"^^rif:iri; likewise,
ex:xyz is a valid abbreviation for this constant, in case
a respective prefix directive
Prefix( ex http://www.example.org/ )
is present in the XML Schema data typespreamble
of RIF, namely xsd:long , xsd:integer , xsd:decimal , xsd:string , xsd:time , and xsd:dateTime , the value spaces andthe lexical-to-value-space mappings are definedRIF document at hand.
Editor's Note: We
might introduce additional shortcuts, e.g. for rif:text defined herein
future versions of this draft.
Relative IRIs in RIF documents are compatibleresolved with RDF's semantics for stringsrespect to the
base IRI. Relative IRIs are combined with named tags [ RDF-SEMANTICS ]. 3base 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 Semantics of Built-ins 3.1 Syntax of Built-ins A RIF built-in function or predicate is a special case6.2.3 of externally defined terms, whichRFC3986)
are definedperformed. Characters additionally allowed in RIF Framework for Logic Dialects and also reproducedIRI references
are treated in the direct definitionsame way that unreserved characters are treated
in URI references, per section 6.5 of Internationalized Resource
Identifiers (IRIs) [RFC-3987].
A single base directive in the preamble
of a RIF Basic Logic Dialect (RIF-BLD).document in RIF'spresentation syntax built-in predicates and functions are syntactically represented as external terms[BLD] or an xml:base directive in a RIF/XML
document define the Base IRI used to resolve relative IRIs per
RFC3986 section 5.1.1, "Base URI Embedded in Content". Section
5.1.2 of RFC3986, "Base URI from the form: 'External' '(' Expr ')' where Expr isEncapsulating Entity" defines
how the Base IRI may come from an encapsulating document, such as a
positional termSOAP envelope with an xml:base directive, containing a RIF
ruleset as defined inpayload. The "Retrieval URI" identified in 5.1.3, Base
"URI from the Retrieval URI", is the URL from which a particular
RIF Framework for Logic Dialects (see alsodocument was retrieved. If none of the above specifies the Base
URI, or several ambiguous base directives are present in the
preamble of a RIF Basic Logic Dialect ). For RIF's normativedocument in presentation syntax, see XML Serialization Syntax for RIF-BLD . RIF-FLD introducesthe
notiondefault Base URI (section 5.1.4 of an external schema to describeRFC3986, "Default Base URI") is
used.
For instance, the constant <./xyz> or "./xyz"^^rif:iri are
both valid abbreviations for the well-formed externally defined terms and their semantics.constant
"http://www.example.org/xyz"^^rif:iri in the special case ofa RIF built-in, external schemas have especially simple form. A built-in named fdocument in
presentation syntax that takes n argumentshas the schema ( ?X 1 ... ?X n ; f(?X 1 ... ?X nsingle base directive
Base( http://www.example.org )
) Here f(?X 1 ... ?X n ) is the actual termin its preamble.
Data types in RIF are symbol spaces which have special
semantics. That is, each data type is used to refer to the built-in (in expressions of the form External(f(?X 1 ... ?X n )) )characterized by a fixed
lexical space, value space and ?X 1 ... ?X nlexical-to-value-mapping.
Definition
(Primitive data type). A primitive data type (or
just a data type, for short) is the list of all variables ina symbol space that term. For convenience,has
Semantic structures are always defined with respect to formulas.a
particular set of data types, denoted by DTS. In a
concrete dialect, DTS always includes the special case ofdata types
supported by that dialect. All RIF built-ins, itdialects must support the following primitive data
types:
Editor's Note:
rif:text (in particular, its identifying IRI) is used to assign truth values to RIF built-in predicates.an AT
RISK feature. We expect a joint effort with the built-in predicates can haveOWL WG to
discuss rif:text and the truth values t or f only.equivalent OWL data type, striving for a
built-in predicateuniform symbol space for such text strings with schema σ , RIF-FLDa language tag.
Their value spaces and RIF-BLD require thatthe truth-valued mapping I truth ο I external ( σ ) must agree withlexical-to-value-space mappings are
defined as follows:
The external schemavalue 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).
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 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
( ?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.
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 [XPath-Functions]
and, when appropriate, we will refer to the definitions in that
specification in order to avoid copying them.
RIF defines guard predicates for all data types in Section Primitive Data Types.
( ?arg1; pred:isDATATYPE ( ?arg1 ) )
Here, DATATYPE is the short name for a data type. As a naming convention we use the capitalized non-prefix XML local name part of the IRI denoting the data type, 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 data types to be used in RIF exchanged rules may define their own guard predicates for these data types. Labels used for such additional guard predicates for data types not mentioned in the present document MAY follow the same naming convention where applicable without creating ambiguities with predicate names defined in the present document.
Editor's Note: The naming convention for guard predicates, particularly whether third parties defining their own datatypes should be encouraged/discouraged to reuse the standard pred: and func: namespaces to define their own built-in predicates and functions, are still under discussion in the working group.
Guard predicates do not depend on a specific intended domain.
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.
( ?arg1; pred:isInteger( ?arg1 ) )
( ?arg1; pred:isDecimal ( ?arg1 ) )
( ?arg1; pred:isDouble ( ?arg1 ) )
( ?arg1; pred:isString ( ?arg1 ) )
( ?arg1; pred:isTime ( ?arg1 ) )
( ?arg1; pred:isDateTime ( ?arg1 ) )
( ?arg1; pred:isDayTimeDuration ( ?arg1 ) )
( ?arg1; pred:isYearMonthDuration ( ?arg1 ) )
( ?arg1; pred:isXMLLiteral ( ?arg1 ) )
( ?arg1; pred:isText ( ?arg1 ) )
Likewise, RIF defines negative guard predicates for all data types in Section Primitive Data Types.
( ?arg1; pred:isNotDATATYPE ( ?arg1 ) )
Here, DATATYPE is the short name for one of the data types mentioned in this document. As a naming convention we use the capitalized non-prefix XML local name part of the IRI denoting the data type, 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 data types to be used in RIF exchanged rules may define their own negative guard predicates for these data types. Labels used for such additional negative guard predicates for data types not mentioned in the present document MAY follow the same naming convention where applicable without creating ambiguities with predicate names defined in the present document.
Editor's Note: The naming convention for negative guard predicates, particularly whether third parties defining their own datatypes should be encouraged/discouraged to reuse the standard pred: and func: namespaces to define their own built-in predicates and functions, are still under discussion in the working group.
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.
( ?arg1; pred:isNotInteger ( ?arg1 ) )
( ?arg1; pred:isNotDecimal ( ?arg1 ) )
( ?arg1; pred:isNotDouble ( ?arg1 ) )
( ?arg1; pred:isNotString ( ?arg1 ) )
( ?arg1; pred:isNotTime ( ?arg1 ) )
( ?arg1; pred:isNotDateTime ( ?arg1 ) )
( ?arg1; pred:isNotDayTimeDuration ( ?arg1 ) )
( ?arg1; pred:isNotYearMonthDuration ( ?arg1 ) )
( ?arg1; pred:isNotXMLLiteral ( ?arg1 ) )
( ?arg1; pred:isNotText ( ?arg1 ) )
Future dialects may extend this list of guards to other data types, but RIF does not require guards for all data types.
RIF defines cast functions for all data types mentioned in this document, i.e. for each data type with IRI DATATYPEIRI there is an external function with the following schema:
( ?arg1; <DATATYPEIRI> ( ?arg1 ) )
We now discuss the built-in.intended domains and mappings for a built-in predicate, its truth value when the arguments are substituted with valuesthese cast
functions.
Editor's Note: In
the domain. As explained in Section Semantics of Built-ins , this correspondsfollowing, we adapt several cast functions from [XPath-Functions]. Due to the
mapping I truth ο I external ( σ )subtle differences in the formal semantics of RIF-FLDe.g. error handling between RIF and RIF-BLD[XPath-Functions], these
definitions might still need refinement in future versions of this
draft.
( ?arg1; xs:long ( ?arg1 ) )
( ?arg1; xs:integer ( ?arg1
) ) and accordingly for all subtypes of
the built-in. Thexs:integer
( ?arg1; xs:decimal ( ?arg1 ) )
( ?arg1; xs:time ( ?arg1 ) )
( ?arg1; xs:dateTime ( ?arg1 ) )
( ?arg1; xs:dayTimeDuration ( ?arg1 ) )
( ?arg1; xs:yearMonthDuration ( ?arg1 ) )
The value spaces of appropriatedata types. These aretypes castable to
xs:DATATYPE according to
Section 17.1 of [XPath-Functions].
Iexternal( ?arg1;
xs:DATATYPE ( ?arg1 ) )(s1) =
s1' such that s1' is the intended domainsconversion of
s1 to the arguments. When an argument falls outsidevalue space 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 supportxs:DATATYPE
according to
Section 17.1 of [XPath-Functions]. Note that these conversions are only
partial and note further that the notionsubtypes of an error, the definitions leavexs:integer
do appear in the valuesconversion table. Conversions from and to subtypes
of xs:integer follow the built-in predicates and functions unspecifiedsame considerations as
xs:integer in such cases. This meansthat for different semantic structures,table, by the valueXPath, XQuery type
hierarchy in
Section 1.6 of I external ( σ )( a 1 ... a n ) can be anything[XPath-Functions].
If one ofthe argumentsargument value is not in itsoutside of the intended domain. Similarly, I truth ο I external ( σ )( a 1 ... a n ) can be t in some interpretations and f in others. This indeterminacydomain or
outside the partial conversions defined in case of an error implies that applications must not make any assumptions about[XPath-Functions], the valuesvalue of
built-ins in such situations. Implementations are even allowed to abort in such cases andthe only safe way to communicate rule sets that contain built-ins among RIF-compliant systemsfunction is to use data type guards . Many built-in functionsleft unspecified and predicates described below are adaptedcan vary from [ XPath-Functions ] and, when appropriate, we will referone semantic
structure to the definitionsanother.
Editor's Note: We
might split this subsection into separate subsections per casting
function in that specificationfuture versions of this document, following the
convention of having one separate subsection per funtcion/predicate
in order to avoid copying them. 4.1 Guard Predicates for Datatypes RIF requires guard predicates for all its supported datatypes. Schema :the schemas for these predicates haverest of the general formdocument. However, it seemed convenient here to
group the cast functions which purely rely on XML Schema datatype
casting into one common subsection.
( ?arg1; pred:is DATATYPExs:string ( ?arg1 )
)
Guard predicates do not depend on a specific intended domain.The union of the value space of rif:text with the value
spaces of data types castable to xs:string according to
the table in
Section 17.1 of [XPath-Functions].
I truth ο Iexternal( ?arg1;
pred:isxs:DATATYPE ( ?arg1 ) )(s1) =
t if and only ifs1' such that s1' is inthe conversion of
s1 to the value space of DATATYPE and f otherwise. Accordingly,xs:string
If the general formargument is outside the intended domain, the value of the
function is left unspecified and can vary from one semantic
structure to another.
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.
( ?arg1; pred:isNot DATATYPErdf:XMLLiteral
( ?arg1 ) )
Negative guard predicates do not depend on a specific intended domain. Mapping: I truth ο I external ( ?arg 1 ; pred:isNot DATATYPE ( ?arg 1 ) )(s 1 ) = fThe intersection of the value space of xs:string with
the lexical space of rdf:XMLLiteral, i.e. an
xs:string can be cast to rdf:XMLLiteral if and
only if s 1its value is in the valuelexical space of
DATATYPErdf:XMLLiteral as defined in Resource
Description Framework (RDF): Concepts and t otherwise. Accordingly, the following schemas are defined: ( ?arg 1 ; pred:isNotInteger ( ?arg 1 ) )Abstract Syntax
Iexternal( ?arg1;
pred:isNotDecimalxs:DATATYPE ( ?arg1 ) ) ( ?arg 1 ; pred:isNotDouble ( ?arg)(s1) ) ( ?arg 1 ; pred:isNotString ( ?arg=
s1 ) ) ( ?arg' such that s1 ; pred:isNotTime ( ?arg' is the XMLLiteral
corresponding to the givne string s1 ) ).
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.
( ?arg1; pred:isNotDateTimerif:text ( ?arg1 )
)
The intersection of the value space of xs:string with all unicode strings ending with '@lang', where lang is a lowercase Unicode character sequence which is a natural language identifier as defined by [RFC-3066].
Iexternal( ?arg1;
pred:isNotDayTimeDurationrif:text ( ?arg1 ) ) ( ?arg 1 ; pred:isNotYearMonthDuration ( ?arg)(s1) ) ( ?arg 1 ; pred:isNotXMLLiteral ( ?arg=
s1 ) ) ( ?arg' where s is a Unicode string of the form
"string@lang" with lang
being a lowercase Unicode character sequence which is a natural
language identifier as defined by [RFC-3066]. Then s1 ; pred:isNotText ( ?arg' is defined exactly such that
the string part of s1 ) ) Future dialects may extend this list' is string and the
lang part is lang.
If the argument value is outside of guardsthe intended domain, the
value of the function is left unspecified and can vary from one
semantic structure to other datatypes, but RIF doesanother.
Editor's Note:
Casting to rif:iri is still under discussion in the
working group since rif:iri is not require guardsa data type. For
all datatypes. 4.3details, we refer to
Issue-61. The following is a strawman proposal which might
still change in future versions of this working draft.
Additionally to the built-in cast functions for Datatypes anddata types we
allow conversions to constants in the rif:iri RIF requiressymbol space
from xs:strings following similar considerations as
conversions from xs:string to xs:anyURI in
[XPath-Functions].
Technically speaking, we cannot proceed as with the other cast
functions for all its supported datatypes, i.e.functions, defining the semantics via a fixed mapping
Iexternal for each datatype DATATYPE there isan external function as follows:schema
:( ?arg1; DATATYPErif:iri ( ?arg1 )
) Intended domain : The, since rif:iri is not a data type with a fixed
value spaces of datatypes castable to DATATYPE accordingspace and fixed lexical-to value mapping. Instead, casts to
rif:iri are defined via an infinite set of axiomatic
equalities in every RIF interpretation as follows.
The tablefollowing equalities hold in Section 17.1 of [ XPath-Functions ]. Mapping: I externalevery RIF interpretation for
each unicode string a:
Thus, although there is no explicit schema
( ?arg1; DATATYPErif:iri ( ?arg1 )
)(s 1) =in RIF, casts between xs:strings 1 ' such thatand
rif:iris 1 ' isare still possible in RIF with the intended
semantics that the IRI represented by a particular string can be
cast to this very string and vice versa.
Editor's Note:
Conversion of s 1from rif:iri to xs:string is still
under discussion in the value space of xsd: DATATYPE accordingworking group since rif:iri is not
a data type. For details, we refer to
Issue-61. The tablefollowing is a strawman proposal which might
still change in Section 17.1future versions of [ XPath-Functions ]. Note that thesethis working draft.
Conversions from rif:iri to xs:string are only partial. If an argument value is outside of the intended domain or outside the partial conversions defined in [ XPath-Functions ], the value ofnot
covered by the xs:string
casting function is left unspecified and can vary from one semantic structure to another.above. Note here, that neither the remaining data types, i.e. the subtypes of xsd:integer and rif:XMLLiteral , norwe cannot apply axiomatic
equalities as for the symbol spacerif:iri do appearcasting function; if we assume
equalitiies
xs:string("http://example.org/iriA"^^rif:iri) =
"http://example.org/iriA"^^xs:string
xs:string("http://example.org/iriB"^^rif:iri) =
"http://example.org/iriB"^^xs:string
this would immediately result in
"http://example.org/iriA"^^xs:string = "http://example.org/iriB"^^xs:string
which is inconsistent in RIF due to the conversion tabledefinition of [ XPath-Functions ], but the following considerations apply:the
lexical-to-value mapping for xs:string which maps two
distinct strings to two distinct domain elements in every
interpretation.
To this end, since conversions from andIRIs (resources) to subtypes of xsd:integer follow the same considerations as xsd:integer in that table, bystrings
are a needed feature for instance for conversions between RDF
formats (see example below), we add a built-in predicate which
supports such conversions.
( ?arg1; pred:iri-to-string ( ?arg1, ?arg1 ) )
The XPath, XQuery type hierarchy in Section 1.6 of [ XPath-Functions ]. Any rif:XMLLiteral can be cast to xsd:stringfirst argument is not restricted by preservinga specific domain, the
lexical value and just changingsecond aregument is the symbol space. An xsd:string can be cast to rdf:XMLLiteralvalue space of xs:string.
Iexternal( ?arg1 ?arg2;
pred:iri-to-string ( ?arg1 ?arg1 )
)(iri1 str1) = t if and only if
its valuestr1 is an element in the lexical space of
rdf:XMLLiteral as defined in Resource Description Framework (RDF): Concepts and Abstract Syntax . Any rif:text can be cast to xsd:string by preserving the lexical value of its string part. Additionally we allow conversions from and torif:iri following the same considerations as conversions fromand to xsd:anyURI . Editor's note: Although rif:iriiri1 is not a datatype,en element of the domain
such that I left conversions from and to rif:iri s(
"str1"^^rif:iri ) = iri1
holds in the listcurrent interpretation.
Note that this definition rather restricts the allowed
interpretations of cast functions,pred:iri-to-string with respect to cover use cases inthe
contextcurrent interpretation of RDF where you want to extract a string from an IRI denoting an RDF resource and vice versa. See alsothe use case mentionedsymbols in http://lists.w3.org/Archives/Public/public-rif-wg/2008Mar/0011.htmlthe rif:iri
symbol space for the first argument and elements of the
xs:string value space for the second argument. The truth
value of the predcate is left unspecified for other elements of the
domain and can vary from one semantic structure to another.
The 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:integerxs:integer, xsd:doublexs:double, or
xsd:decimalxs: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 [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 ?arg2; func:numeric-subtract( ?arg1 ?arg2) )
(?arg1 ?arg2; func:numeric-multiply( ?arg1 ?arg2) )
(?arg1 ?arg2; func:numeric-divide( ?arg1 ?arg2) )
The value spaces of xsd:integerxs:integer, xsd:doublexs:double, or
xsd:decimalxs:decimal for the first argument and xsd:integerxs:integer,
xsd:doublexs:double, or xsd:decimalxs:decimal without zero for the
second argument.
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. 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.
(?arg1 ?arg2; func:numeric-integer-divide( ?arg1 ?arg2) )
The value spaces of xsd:integerxs:integer, xsd:doublexs:double, or
xsd:decimalxs:decimal for the first argument and xsd:integerxs:integer,
xsd:doublexs:double, or xsd:decimalxs:decimal without zero for the
second argument.
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.
(?arg1 ?arg2; func:numeric-mod( ?arg1 ?arg2) )
The value spaces of xsd:integerxs:integer, xsd:doublexs:double, or
xsd:decimalxs:decimal for the first argument and xsd:integerxs:integer,
xsd:doublexs:double, or xsd:decimalxs:decimal without zero for the
second argument.
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.
(?arg1 ?arg2; pred:numeric-equal(?arg1 ?arg2))
The value spaces of xsd:integerxs:integer, xsd:doublexs:double, or
xsd:decimalxs:decimal for both arguments.
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 are defined acordingly with respect to their corresponding operators in [XPath-Functions].
(?arg1 ?arg2; pred:numeric-less-than( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:numeric-greater-than( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:numeric-less-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:numeric-greater-than-or-equal( ?arg1 ?arg2) )
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( str1, str2) ) and External( func:concat3( str1 str2 str3 ) ) we equally allow simply to write 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.
( ?comparand1 ?comparand2; func:compare1(?comparand1 ?comparand2) )
( ?comparand1 $comparand2 $collation; func:compare2(?comparand1 ?comparand2 ?collation) )
The value space of xsd:stringxs:string for all arguments.
Iexternal(
( ?comparand1 ?comparand2;
func:compare1(?comparand1 ?comparand2)
)(s1 s2) = res such that res =
-1, 0,-1, 0, or 1,0 (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.
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, pred:string-greater-than, 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 data types.
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.
( ?arg1; func:concat1(1 ) )
( ?arg1 ?arg2; func:concat2(?arg1 ?arg2 ) )
...
( ?arg1 ?arg2 ... ?argn; func:concatn(?arg1 ?arg2 ... ?argn ) )
Following the definition of fn:concat
this function accepts xs:anyAtomicType arguments and casts them to
xsd:stringxs:string. Thus, the intended domain for all arguments is
the union of all value spaces castable to String xsd:stringxs:string
as defined in Section Cast
Functions and Conversion Predicates for DatatypesData Types and rif:iri
above.
Returns the xsd:stringxs: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.
( ?arg1 ?arg2; func:string-join2(?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?arg3; func:string-join2(?arg1 ?arg2 ?arg3 ) )
...
( ?arg1 ?arg2 ... ?argn; func:string-joinn(?arg1 ?arg2 ... ?argn ) )
The value space of xsd:stringxs:string for all arguments.
Returns a xsd:stringxs: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.
( ?sourceString ?startingLoc; func:substring1( ?sourceString ?startingLoc) )
( ?sourceString ?startingLoc ?length ; func:substring2( ?sourceString ?startingLoc ?length) )
The value space of xsd:stringxs:string for ?sourceString
and the union of the value spaces of xsd:integerxs:integer,
xsd:longxs:long, or xsd:decimalxs: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:stringxs:string for ?arg.
Returns an xsd:integerxs:integer equal to the length in characters
of the argument if it is a xsd:stringxs: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:stringxs: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:stringxs: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:stringxs:string for ?arg.
This function encodes reserved characters in an
xsd:stringxs: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:stringxs:string for ?iri.
This function converts an xsd:stringxs: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:stringxs: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:stringxs: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:stringxs: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.
( ?input ?pattern ?replacement; func:replace1( ?input ?pattern ?replacement ) )
( ?input ?pattern ?replacement ?flags; func:replace2( ?input ?pattern ?replacement ?flags ) )
The value space of xsd:stringxs:string for all arguments.
The function returns the xsd:stringxs: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.
( ?arg1 ?arg2; pred:contains1( ?arg1 ?arg2 ) )
( ?arg1 ?arg2 ?collation ; pred:contains2( ?arg1 ?arg2 ?collation ) )
The value space of xsd:stringxs: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:stringxs: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.
(?arg1 ?arg2; fn:ends-with1( ?arg1 ?arg2 ) )
(?arg1 ?arg2 ?collation; fn:ends-with2( ?arg1 ?arg2 ?collation) )
The value space of xsd:stringxs: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.
( ?input ?pattern; pred:matches1( ?input ?pattern) )
( ?input ?pattern ?flags; pred:matches2( ?input ?pattern ?flags ) )
The value space of xsd:stringxs: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 datatypesdata types 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:gDayxs:dateTime, xs:date, xs:time,
xs:gYearMonth, xs:gYear, xs:gMonthDay, xs:gMonth, xs: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.xs:integers. The value of the second component is an xsd:decimalxs:decimal and
the value of the timezone component is an xsd:dayTimeDuration.xs:dayTimeDuration. For
all the date/time datatypes,data types, the timezone property is optional and
may or may not be present. Depending on the datatype,data type, 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:dateTimexs:dateTime values, this local value must be translated or
normalized to UTC.
( ?arg ; func:year-from-dateTime( ?arg ) )
The value space of xsd:dateTimexs:dateTime for ?arg.
Iexternal( ?arg ;
func-year-from-dateTime( ?argfunc: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:dateTimexs:dateTime for ?arg.
Returns an xsd:integerxs: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:dateTimexs:dateTime for ?arg.
Returns an xsd:integerxs: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:dateTimexs:dateTime for ?arg.
Returns an xsd:integerxs: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:dateTimexs:dateTime for ?arg.
Returns an xsd:integerxs: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:dateTimexs:dateTime for ?arg.
Returns an xsd:decimalxs: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:datexs:date for ?arg.
Returns an xsd:integerxs: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:datexs:date for ?arg.
Returns an xsd:integerxs: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:datexs:date for ?arg.
Returns an xsd:integerxs: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:timexs:time for ?arg.
Returns an xsd:integerxs: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:timexs:time for ?arg.
Returns an xsd:integerxs: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:timexs:time for ?arg.
Returns an xsd:decimalxs: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 datatypesdata types castable to
xsd:yearMonthDurationxs:yearMonthDuration according to the table in Section
17.1 of [XPath-Functions].
Returns an xsd:integerxs:integer representing the years component
in the value of ?arg. The result is obtained by
casting ?arg to an xsd:yearMonthDurationxs: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 datatypesdata types castable to
xsd:yearMonthDurationxs:yearMonthDuration according to the table in Section
17.1 of [XPath-Functions].
Returns an xsd:integerxs:integer representing the months component
in the value of ?arg. The result is obtained by
casting ?arg to an xsd:yearMonthDurationxs: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 datatypesdata types castable to
xsd:dayTimeDurationxs:dayTimeDuration according to the table in Section 17.1
of [XPath-Functions].
Returns an xsd:integerxs:integer representing the days component
in the value of ?arg. The result is obtained by
casting ?arg to an xsd:dayTimeDurationxs: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 datatypesdata types castable to
xsd:dayTimeDurationxs:dayTimeDuration according to the table in Section 17.1
of [XPath-Functions].
Returns an xsd:integerxs:integer representing the hours component
in the value of ?arg. The result is obtained by
casting ?arg to an xsd:dayTimeDurationxs: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 datatypesdata types castable to
xsd:dayTimeDurationxs:dayTimeDuration according to the table in Section 17.1
of [XPath-Functions].
Returns an xsd:integerxs:integer representing the minutes
component in the value of ?arg. The result is obtained by
casting ?arg to an xsd:dayTimeDurationxs: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 datatypesdata types castable to
xsd:dayTimeDurationxs:dayTimeDuration according to the table in Section 17.1
of [XPath-Functions].
Returns an xsd:decimalxs:decimal representing the seconds
component in the value of ?arg. The result is obtained by
casting ?arg to an xsd:dayTimeDurationxs: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.
( ?arg ; func:timezone-from-dateTime( ?arg ) )
The value space of xsd:dateTimexs:dateTime.
Returns the timezone component of ?arg if any. If $arg has
a timezone component, then the result is an
xsd:dayTimeDurationxs: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 can vary from one semantic structure to another.
The following two functions are defined analogously for intended
domains xsd:datexs:date and xsd:time 20.xs:time
( ?arg ; func:timezone-from-date( ?arg ) )
( ?arg ; func:timezone-from-time( ?arg ) )
( ?arg1 ?arg2; func:subtract-dateTimes( ?arg1 ?arg2 ) )
Subtracts two xs:dateTimes. Returns an xs:xs:dayTimeDuration.
( ?arg1 ?arg2; func:subtract-dates( ?arg1 ?arg2 ) )
Subtracts two xs:dates. Returns an xs:xs:dayTimeDuration.
( ?arg1 ?arg2; func:subtract-times( ?arg1 ?arg2 ) )
Subtracts two xs:times. Returns an xs:xs:dayTimeDuration.
( ?arg1 ?arg2; func:add-yearMonthDurations( ?arg1 ?arg2 ) )
Adds two xs:yearMonthDurations. Returns an xs:yearMonthDuration.
( ?arg1 ?arg2; func:subtract-yearMonthDurations( ?arg1 ?arg2 ) )
Subtracts one xs:yearMonthDuration from another. Returns an xs:yearMonthDuration.
( ?arg1 ?arg2; func:multiply-yearMonthDuration( ?arg1 ?arg2 ) )
Multiplies an xs:yearMonthDuration by an xs:double. Returns an xs:yearMonthDuration.
( ?arg ; func:timezone-from-date( ?arg( ?arg1 ?arg2 ;
func:divide-yearMonthDuration( ?arg1 ?arg2
) )
21. fn:timezone-from-dateDivides an xs:yearMonthDuration by an
xs:double. Returns an xs:yearMonthDuration.
( ?arg ; func:timezone-from-time( ?arg( ?arg1 ?arg2;
func:divide-yearMonthDuration-by-yearMonthDuration( ?arg1 ?arg2
) )
22. op:add-yearMonthDurationsDivides an xs:yearMonthDuration by an
xs:yearMonthDuration. Returns an xs:decimal.
( ?arg ; func:add-yearMonthDurations( ?arg( ?arg1 ?arg2;
func:add-dayTimeDurations( ?arg1 ?arg2
) )
Adds two xsd:yearMonthDurationxs:dayTimeDurations. Returns an
xsd:yearMonthDurationxs:dayTimeDuration.
( ?arg ; func:subtract-yearMonthDurations( ?arg( ?arg1 ?arg2;
func:subtract-dayTimeDurations( ?arg1 ?arg2
) )
Subtracts one xsd:yearMonthDurationxs:dayTimeDuration from another. Returns
an xs:yearMonthDurationxs:dayTimeDuration.
( ?arg ; func:multiply-yearMonthDuration( ?arg( ?arg1 ?arg2 ;
func:multiply-dayTimeDuration( ?arg1 ?arg2
) )
Multiplies an xsd:yearMonthDurationxs:dayTimeDuration by a
xs:double. Returns an xs:dayTimeDuration.
( ?arg1 ?arg2 ; func:divide-dayTimeDuration( ?arg1 ?arg2 ) )
Divides an xs:dayTimeDuration by an xsd:doublexs:double.
Returns an xsd:yearMonthDurationxs:dayTimeDuration.
( ?arg ; func:divide-yearMonthDuration( ?arg( ?arg1 ?arg2 ;
func:divide-dayTimeDuration-by-dayTimeDuration( ?arg1 ?arg2
) )
Divides an xsd:yearMonthDurationxs:dayTimeDuration by an
xsd:doublexs:dayTimeDuration. Returns an xsd:yearMonthDurationxs:decimal.
( ?arg ; func:divide-yearMonthDuration-by-yearMonthDuration( ?arg( ?arg1 ?arg2 ;
func:add-yearMonthDuration-to-dateTime( ?arg1 ?arg2
) )
Adds a xs:yearMonthDuration (?arg2) to a xs:dateTime (?arg1). Returns an xs:dateTime.
( ?arg1 ?arg2 ; func:add-yearMonthDuration-to-date( ?arg1 ?arg2 ) )
Adds a xs:yearMonthDuration (?arg2) to a xs:date (?arg1). Returns an xs:date.
( ?arg1 ?arg2 ; func:add-dayTimeDuration-to-dateTime( ?arg1 ?arg2 ) )
Adds a xs:dayTimeDuration (?arg2) to a xs:dateTime (?arg1). Returns an xs:dateTime.
( ?arg1 ?arg2 ; func:add-dayTimeDuration-to-date( ?arg1 ?arg2 ) )
Adds a xs:dayTimeDuration (?arg2) to a xs:date (?arg1). Returns an xs:date.
( ?arg1 ?arg2 ; func:add-dayTimeDuration-to-time( ?arg1 ?arg2 ) )
Adds a xs:dayTimeDuration (?arg2)
Divides an xsd:yearMonthDuration by an xsd:yearMonthDuration .to a xs:time (?arg1). Returns an
xsd:decimalxs:time.
( ?arg ; func:add-dayTimeDurations( ?arg( ?arg1 ?arg2 ;
func:subtract-yearMonthDuration-from-dateTime( ?arg1 ?arg2
) )
Adds two xsd:dayTimeDuration s.Subtracts a xs:yearMonthDuration
(?arg2) from a xs:dateTime
(?arg1). Returns an xsd:dayTimeDurationxs:dateTime.
( ?arg ; func:subtract-dayTimeDurations( ?arg( ?arg1 ?arg2 ;
func:subtract-yearMonthDuration-from-date( ?arg1 ?arg2
) )
Subtracts one xsd:dayTimeDurationa xs:yearMonthDuration
(?arg2) from another.a xs:date
(?arg1). Returns an xsd:dayTimeDurationxs:date.
( ?arg ; func:multiply-dayTimeDuration( ?arg( ?arg1 ?arg2 ;
func:subtract-dayTimeDuration-from-dateTime( ?arg1 ?arg2
) )
Multiplies an xsd:dayTimeDuration bySubtracts a xsd:double .xs:dayTimeDuration
(?arg2) from a xs:dateTime
(?arg1). Returns an xsd:dayTimeDurationxs:dateTime.
( ?arg ; func:divide-dayTimeDuration( ?arg( ?arg1 ?arg2 ;
func:subtract-dayTimeDuration-from-date( ?arg1 ?arg2
) )
Divides an xsd:dayTimeDuration by an xsd:double .Subtracts a xs:dayTimeDuration
(?arg2) from a xs:date
(?arg1). Returns an xsd:dayTimeDurationxs:date.
( ?arg ; func:divide-dayTimeDuration-by-dayTimeDuration( ?arg( ?arg1 ?arg2 ;
func:subtract-dayTimeDuration-from-time( ?arg1 ?arg2
) )
Divides an xsd:dayTimeDuration by an xsd:dayTimeDuration .Subtracts a xs:dayTimeDuration
(?arg2) from a xs:time
(?arg1). Returns an xsd:decimalxs:time.
( ?arg1 ?arg2; pred:dateTime-equal( ?arg1 ?arg2) )
The value space of xsd:dateTimexs:dateTime for both arguments.
where Itruth ο Iexternal( ?arg1 ?arg2; pred:dateTime-equal( ?arg1 ?arg2 ) )(s1 s2) = t
if and only if op:dateTime-equal(s1, s2) returns true, as defined in [XPath-Functions], f in case false is returned.
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 schemata 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 and mapping as needed.
( ?arg1 ?arg2; pred:dateTime-less-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:dateTime-greater-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:date-equal( ?arg1 ?arg2) )
( ?arg1 ?arg2; pred:date-less-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:date-greater-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:time-equal( ?arg1 ?arg2) )
( ?arg1 ?arg2; pred:time-less-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:time-greater-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:duration-equal( ?arg1 ?arg2) )
The union of the value spaces of xsd:dayTimeDurationxs:dayTimeDuration and
xsd:yearMonthDurationxs:yearMonthDuration for both arguments.
( ?arg1 ?arg2; pred:dayTimeDuration-less-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:dayTimeDuration-greater-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:yearMonthDuration-less-than(?arg1 ?arg2 ) )
( ?arg1 ?arg2; pred:yearMonthDuration-greater-than(?arg1 ?arg2 ) )
(?arg1 ?arg2; pred:dateTime-less-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:dateTime-greater-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:date-less-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:date-greater-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:time-less-than-or-equal( ?arg1 ?arg2) )
(?arg1 ?arg2; pred:time-greater-than-or-equal( ?arg1 ?arg2) )
Editor's Note: No
less-than-or-equal or greater-than-or-equal
predicates are defined in this draft for durations, since thethere are
no separate equalsop:dayTimeDuration-equal nor
op:yearMonthDuration-equalpredicates for yearMonthDuration and dayTimeDurationin [XPath-Functions ].], but only a
common predicate op:duration-equal. Future versionversions of
this working draft may resolve this by introducing separatenew equality
predicates pred:dayTimeDuration-equal and
pred:yearMonthDuration-equal with restricted intended
domains.
The 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""^^xs:string otherwise.
Editor's Note: The current name of this function is still under disscussion in the working group. Alternative proposals include e.g. func:lang-from-text rather following the XPath/XQuery naming convention for extraction functions from data types than the SPARQL naming convention.
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])(?X ?Y; ?X["foo"^^xs:string->?Y]) or
(?V; "pred:isTime"^^rif:iri(?V)), is that
?X["foo"^^xsd:string->?Y]?X["foo"^^xs: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])External("http://foo.bar.com"^^rif:iri["foo"^^xs:string->"123"^^xs:integer])
and External("pred:isTime"^^rif:iri("22:33:44"^^xsd: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 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 is 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.