Serialization parameters
Saxon provides a number of additional serialization parameters, with names in the Saxon namespace. These can be specified as attributes on the xsl:output and xsl:result-document elements (XSLT-only), in the Query prolog (XQuery only), as parameters in the fn:serialize() function, or as extra parameters on the Query or Transform command line. They can also be specified in the query or transformation API.
|
|
Available with the XML, HTML, and XHTML output methods, to control the order in
which attributes appear within an element start tag (in the absence of the
property the order of attributes is unpredictable).
The value of the parameter is a list of tokens, each of which is either a QName or
the token "*" to match unspecified attributes. Attributes whose names are
listed before the "*" token appear first, in the order they are listed; other
unlisted attributes follow, sorted first by namespace URI and then by local-name, and finally any attributes
whose names appear after the "*" appear at the end.
For example |
|
|
Available with the XML output method, to request that the serialized XML conforms to the W3C XML Canonicalization 1.1 specification (C14N). This can be useful, for example, when test results are to be compared. Specifically, this option changes XML serialization as follows:
Specifying |
|
|
Allows greater control over how non-ASCII characters will be represented on output. When the output method is XML, two values are supported: When the output method is HTML, the value may hold two strings, separated by a
semicolon. The first string defines how non-ASCII characters within the
character encoding will be represented, the values being |
|
|
When the output method is XML with |
|
|
When the output method is XML, HTML, or XHTML with |
|
|
Default value 80. With the XML output method, attributes are output on a new line if they would otherwise extend beyond this column position. With the HTML output method, text lines are split at this line length when possible. In releases 9.2 and earlier, the HTML output method attempted to split lines that exceeded 120 characters in length. |
|
|
Default value x10. Defines the string that is used by the text output method to represent a newline. The Windows line ending x0Cx0A (CRLF) may sometimes be preferred to the default of a single newline character. |
|
|
XSLT only. Used to direct the output to another stylesheet. The value is the URL
of a stylesheet that should be used to process the output stream. In this case
the output stream must always be pure XML, and attributes that control the
format of the output (e.g. This serialization property is available only on xsl:output declarations and xsl:result-document instructions. It cannot be supplied as an attribute to any of the various APIs that control serialization; nor can it be used on the command line. It is not supported as an XQuery serialization parameter. Supplying a zero-length string is equivalent to omitting the attribute, except that it can be used to override a previous setting. If the value is a relative URI, it is interpreted relative to the base URI of the
stylesheet element ( |
|
|
Available with the JSON output method, to control the order in
which properties appear within the serialization of a map/object (in the absence of the
property the order of properties is unpredictable).
The value of the parameter is a list of tokens, in which the token "*" is treated specially. Properties whose names are
listed before the "*" token appear first, in the order they are listed; other
unlisted properties follow, sorted alphabetically, and finally any properties
whose names are listed after the "*" appear at the end.
For example |
|
|
Relevant only when using the text output method. If set to This enables non-XML characters, notably binary zero, to be output. For example, given
outputs the Unicode character with codepoint zero ("NUL"), while
outputs the value of the |
|
|
Affects the handling of result documents that contain multiple top-level elements or top-level text nodes. The W3C specifications allow such a result document, even though it is not a well-formed XML document. It is, however, a well-formed external general parsed entity, which means it can be incorporated into a well-formed XML document by means of an entity reference. The default is Note also that namespace undeclarations of the form |
|
|
If set to This can be useful if the serialized XML/HTML is to be subsequently wrapped in double quotes,
for example as part of a JSON text, or within a Java string literal. It does not eliminate the
need to escape double quotes (using The property is ignored in the case of attributes affected by character maps, where single or double quotes are used intelligently based on the actual content of the attribute. |
|
|
Relevant only when output is sent to a user-written For this to work, the code must be compiled with tracing enabled. This can be
achieved by setting the option |