Copyright © 2012-2013 Claudius Teodorescu, published by the EXPath Community Group under the W3C Community Contributor License Agreement (CLA) . A human-readable summary is available.
This specification was published by the EXPath Community Group . It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups .
This proposal defines a module for handling various datatypes. It has been designed to be compatible with XQuery 3.0 and XSLT 3.0, as well as any other standard based on XPath 3.0.
As this is a work in progress, more details about it can be found at Datatype Conversion Functions Comparison.
1 Introduction
1.1 Namespace conventions
1.2 Error management
2 Datatype Systems
2.1 The datatypes:register-datatype-system function
2.2 The datatypes:deregister-datatype-system function
3 Conversions
3.1 xs:base64Binary to other datatypes
3.1.1 The datatypes:base64Binary-to-byte function
3.1.2 The datatypes:base64Binary-to-string function
3.2 xs:byte to other datatypes
3.2.1 The datatypes:byte-to-base64Binary function
3.2.2 The datatypes:byte-to-hexBinary function
3.3 xs:hexBinary to other datatypes
3.3.1 The datatypes:hexBinary-to-byte function
3.3.2 The datatypes:hexBinary-to-string function
3.4 xs:string to other datatypes
3.4.1 The datatypes:string-to-base64Binary function
3.4.2 The datatypes:string-to-hexBinary function
3.4.3 The datatypes:string-to-integer function
3.5 xs:integer to other datatypes
3.5.1 The datatypes:integer-to-string function
4 User defined datatypes
4.1 The datatypes:define function
5 Mappings
5.1 The datatypes:set-mapping function
5.2 The datatypes:get-mapping function
5.3 The datatypes:delete-mapping function
6 Characterizing Operations
This module is designed for datatypes handling, providing conversions between datatypes that are not covered by casts mentioned in [XPath and XQuery Functions and Operators 3.0], as well as other functions related to datatypes.
The module defined by this document defines functions and elements in the namespace
http://expath.org/ns/datatypes
. In this document, the
datatypes
prefix, when used, is bound to this namespace URI.
Error codes are defined in the namespace http://expath.org/ns/error
. In
this document, the err
prefix, when used, is bound to this namespace
URI.
These are functions allowing operations on datatype systems. The implementations should register by default the XML datatype system ([W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures]). Other datatype systems are implementation dependent.
These functions are for conversions between various datatypes.
xs:base64Binary
to other datatypes
These functions provide conversion from xs:base64Binary datatype to other datatypes.
datatypes:base64Binary-to-byte
function
This function converts from xs:base64Binary to xs:byte.
datatypes:base64Binary-to-byte
($data asxs:base64Binary?
) asxs:byte*
$data
is the data to be converted.
datatypes:base64Binary-to-string
function
This function converts from xs:base64Binary to xs:string.
datatypes:base64Binary-to-string
($data asxs:base64Binary?
) asxs:string?
datatypes:base64Binary-to-string
($data asxs:base64Binary?
, $encoding as xs:string) asxs:string?
$data
is the data to be converted.
$encoding
is the encoding used for conversion. The default value is UTF-8. If it is specified
an unsupported encoding, this
is an error [err:DT01].
xs:byte
to other datatypes
These functions provide conversion from xs:byte datatype to other datatypes.
xs:hexBinary
to other datatypes
These functions provide conversion from xs:hexBinary datatype to other datatypes.
datatypes:hexBinary-to-byte
function
This function converts from xs:hexBinary to xs:byte.
datatypes:hexBinary-to-byte
($data asxs:hexBinary?
) asxs:byte*
$data
is the data to be converted.
datatypes:hexBinary-to-string
function
This function converts from xs:hexBinary to xs:string.
datatypes:hexBinary-to-string
($data asxs:hexBinary?
) asxs:string?
datatypes:hexBinary-to-string
($data asxs:hexBinary?
, $encoding as xs:string) asxs:string?
$data
is the data to be converted.
$encoding
is the encoding used for conversion. The default value is UTF-8. If it is specified
an unsupported encoding, this
is an error [err:DT01].
xs:string
to other datatypes
These functions provide conversion from xs:string datatype to other datatypes.
datatypes:string-to-base64Binary
function
This function converts from xs:string to xs:base64Binary.
datatypes:string-to-base64Binary
($data asxs:string?
) asxs:base64Binary?
datatypes:string-to-base64Binary
($data asxs:string?
, $encoding as xs:string) asxs:base64Binary?
$data
is the data to be converted.
$encoding
is the encoding used for conversion. The default value is UTF-8. If it is specified
an unsupported encoding, this
is an error [err:DT01].
datatypes:string-to-hexBinary
function
This function converts from xs:string to xs:hexBinary.
datatypes:string-to-hexBinary
($data asxs:string?
) asxs:hexBinary?
datatypes:string-to-hexBinary
($data asxs:string?
, $encoding as xs:string) asxs:hexBinary?
$data
is the data to be converted.
$encoding
is the encoding used for conversion. The default value is UTF-8. If it is specified
an unsupported encoding, this
is an error [err:DT01].
datatypes:string-to-integer
function
This function converts from xs:string to xs:integer.
datatypes:string-to-integer
($data asxs:string?
, $radix asxs:integer
) asxs:integer?
$data
is the data to be converted.
$radix
is the radix used to provide the conversion of $data ($data is considered being in
radix $radix).
These are functions related to mappings between various datatype systems.
datatypes:set-mapping
function
This function sets mappings between datatypes belonging to different datatype systems. One can map one or more source datatypes to one target datatype, or one source datatype to one or more target datatypes.
datatypes:set-mapping
($source-datatype asxs:string+
, $target-datatype asxs:string+
) asempty()
$source-datatype
is the source datatype to set the mapping for.
$target-datatype
is the target datatype to set the mapping for.
datatypes:get-mapping
function
This function returns the mapping(s) between datatypes belonging to different datatype systems. If there are more target datatypes mapped, they are all returned.
datatypes:get-mapping
($source-datatype asxs:string
, $target-datatype-system asxs:anyURI
) asxs:string*
$source-datatype
is the datatype to get the mapping(s) of.
$target-datatype-system
is the datatype system to get the mapping(s) from.
datatypes:delete-mapping
function
This function deletes the mapping between datatypes belonging to different datatype systems. If they are more source or target datatypes, each individual mapping between each one of them will be deleted.
datatypes:delete-mapping
($source-datatype asxs:string+
, $target-datatype asxs:string+
) asempty()
$source-datatype
is the source datatype to delete the mapping for.
$target-datatype
is the target datatype to delete the mapping for.