The Adaptive output method serializes the instance of the data model into a human readable form for the purposes of debugging query results. The intention of this is to allow any valid XDM instance to be serialized without raising a serialization error. Sequence normalization is not performed for this output method.
Each item in the supplied sequence is serialized individually as
follows, with an occurrence of the chosen item-separator
between successive items.
A document, element, text, comment, or processing instruction node is serialized using the XML output method described in 5 XML Output Method.
An attribute or namespace node is serialized as if it had a containing
element node. For example an
attribute node might be serialized as the string
xsi:type="xs:integer"
; a namespace node might be
serialized as
xmlns:sns="http://example.com/sample-namespace"
.
Note:
This may result in output of QNames containing prefixes whose binding is not displayed.
An atomic valueXP31 is serialized as follows:
An instance of xs:boolean
is serialized as true()
or false()
.
An instance of xs:string
, xs:untypedAtomic
or xs:anyURI
is serialized by enclosing the value in double
quotation marks and doubling any quotes within the value; or optionally by enclosing
the value
in apostrophes and doubling any apostrophes within the value.
The resulting value is then serialized using the Text output method
described in 8 Text Output Method.
Note:
The Text output method will apply character expansion and encoding rules to this string as specified by the serialization parameters.
An instance of xs:integer
or xs:decimal
is serialized by converting
the value to a string using the fn:string
function.
An instance of xs:double
is serialized by applying the function
format-number(?, '0.0##########################e0')
using the following default decimal format properties:
Property name | Property value |
---|---|
decimal-separator |
The period character (.) |
exponent-separator |
The character (e) |
grouping-separator |
The comma character (,) |
zero-digit |
The Western digit zero (#x30). |
digit |
The number sign character (#) |
infinity |
The string "INF" |
NaN |
The string "NaN" |
minus-sign |
The hyphen-minus character (#x2D) |
An instance of xs:QName
or xs:NOTATION
is serialized
as a URI-qualified name (that is, in the form Q{uri}local
).
An atomic value of any other type is serialized using the syntax of a constructor
function: xs:TYPE("VAL")
where TYPE
is the name of the primitive
type, and VAL
is the result of applying the fn:string()
function.
For example, xs:date("2015-07-17")
.
The resulting string is then serialized using the Text output method
described in 8 Text Output Method.
An array item is serialized using the syntax
of a
SquareArrayConstructor
XP31,
that is as [member,member, ... ]
. The members, which in general are sequences,
are serialized in the form (item,item, ...)
where the items are serialized by
applying these rules recursively. The items are separated by commas
(not by the item-separator character). The enclosing parentheses are optional if the
sequence
has length one.
Note:
The serializer should avoid outputting the parentheses if it is able to determine the length of the sequence before serializing the first item; but it is allowed to output parentheses around a singleton if this avoids buffering data in memory.
A map item is serialized using the syntax of a
MapConstructor
XP31, that is as map{key:value, key:value, ...}
.
The order of entries is implementation-dependent. The key is serialized by applying
the rules
for serializing an atomic value. The values are serialized in the same way as the
members of an array (see above).
A function item is
serialized to the representation
name#A
where
name is
a representation of
the function name
and A is the arity.
If the function name is in one of the namespaces
http://www.w3.org/2005/xpath-functions
,
http://www.w3.org/2005/xpath-functions/math
,
http://www.w3.org/2005/xpath-functions/map
,
http://www.w3.org/2005/xpath-functions/array
or
http://www.w3.org/2001/XMLSchema
,
then the name is output as a lexical QName using the conventional prefix
fn
, math
, map
, array
, or xs
as appropriate; if it is in any other namespace or in no namespace, then the name
is
output as a URI-qualified name (that is, Q{uri}local
).
If the function is anonymous,
name is replaced by the string
(anonymous-function)
.
Note:
The following examples illustrate this rule:
fn:exists#1
is serialized as function fn:exists#1
Q{http://www.w3.org/2005/xpath-functions}exists#1
is serialized as fn:exists#1
function($a) { $a }
is serialized as (anonymous-function)#1
math:pi#0
is serialized as math:pi#0
Character maps are applied (a) when nodes are serialized using the XML output method, and (b) to any value represented as a string enclosed in quotation marks.
Optionally, in all the above constructs, characters whose visual
representation is ambiguous (for example tab or non-breaking-space) may be represented
in the
form of an XML numeric character reference (for example 	
or  
)
Note:
In many cases the serialization of an item conforms to the syntax of an XQuery expression whose result is that item. There are exceptions, however: for example the syntax will not be valid XQuery in the case of free-standing attribute or namespace nodes, or QName values, or anonymous functions; and where it is valid XQuery, the result of evaluating the expression will not necessarily be identical to the original: for example, the distinction between strings and untypedAtomic values is lost.
If any value cannot be output because doing so would cause a serialization error, the behavior is implementation-defined.
If the output is sent to a destination that allows hyperlinks to be included in the generated text, then the serializer MAY include implementation-dependent hyperlinks to provide additional information for example:
to allow the type of atomic valuesXP31 to be ascertained.
to allow the namespace binding of prefixes to be ascertained.
to provide further information about the cause of error indicators.
For some item types the Adaptive output method will delegate serialization to other
output methods.
With the exception of the byte-order-mark
serialization parameter, all serialization parameters,
if set, will be passed down to the serialization method that is applied to each item
in the supplied sequence.
Only the item-separator
and byte-order-mark
parameters are directly applicable to the Adaptive output method.
version
Parameter
The version
parameter is not directly
applicable to the Adaptive output method.
html-version
Parameter
The html-version
parameter is not directly applicable to the
Adaptive output method.
encoding
Parameter
The encoding
parameter is not directly applicable to the
Adaptive output method.
indent
and suppress-indentation
Parameters
The indent
and
suppress-indentation
parameters are not directly applicable to the
Adaptive output method.
cdata-section-elements
Parameter
The cdata-section-elements
parameter is not directly
applicable to the Adaptive output method.
omit-xml-declaration
and standalone
Parameters
The omit-xml-declaration
and standalone
parameters are not directly applicable to the Adaptive output
method.
Note:
If these parameters call for an XML declaration to be serialized, then an XML declaration is to be output each time the Adaptive output method delegates the serialization of a node to the XML output method. If several node items appear in the sequence to be serialized or as values in maps or arrays to be serialized, then the output will contain several XML declarations.
doctype-system
and doctype-public
Parameters
The doctype-system
and doctype-public
parameters are not directly applicable to the Adaptive output
method.
undeclare-prefixes
Parameter
The undeclare-prefixes
parameter is not directly applicable to the
Adaptive output method.
normalization-form
Parameter
The normalization-form
parameter is not directly applicable to the
Adaptive output method.
media-type
Parameter
The media-type
parameter is not directly applicable to the Adaptive output
method.
use-character-maps
Parameter
The use-character-maps
parameter is directly applicable to the
Adaptive output method only as elsewhere specified.
byte-order-mark
Parameter
The byte-order-mark
parameter is applicable to the
Adaptive output method.
See
3 Serialization Parameters for more information.
Note:
A byte order mark can appear only once in the serialized output. Therefore, this parameter does not get passed down to any delegated output method.
escape-uri-attributes
Parameter
The escape-uri-attributes
parameter is not directly applicable to the
Adaptive output method.
include-content-type
Parameter
The include-content-type
parameter is not directly applicable to the
Adaptive output method.
item-separator
Parameter
The item-separator
serialization parameter is directly applicable to the
Adaptive output method. It specifies the string to be inserted between
adjacent serialized items.
If the item-separator
parameter is absent, the string
"

"
(a single newline character) is used by the Adaptive output method as the
item-separator
value.