# Additional serialization parameters

Saxon provides a number of additional serialization parameters: these have 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), or as extra parameters on the Query or Transform command line. They can also be specified in the query or transformation API.

For example, to request an indentation depth of on column, specify `!{http://saxon.sf.net/}indent-spaces=1` on the command line.

In XQuery, Saxon allows both standard serialization options and Saxon-specific serialization parameters to be specified by means of an option declaration in the query prolog. For example:

    declare namespace saxon="http://saxon.sf.net/";
    declare option "saxon:output indent=yes";
    declare option "saxon:output saxon:indent-spaces=3";

The method parameter

The `method` attribute of `xsl:output` can take the standard values "xml", "html", "xhtml", or "text", or a QName.

If a QName is specified, the local name must be the fully-qualified class name of a class that implements either the SAX2 `org.xml.sax.ContentHandler` interface, or the `net.sf.saxon.event.Receiver` interface. If such a value is specified, output is directed to a newly-created instance of the user-supplied class. You can pass additional information to this class by means of extra user-defined attributes on the `xsl:output` element.

The prefix of the QName must correspond to a valid namespace URI. It is recommended to use the Saxon URI "http://saxon.sf.net/", but this is not enforced.

The saxon:indent-spaces attribute

When the output is XML or HTML with indent="yes", the saxon:indent-spaces attribute may be used to control the amount of indentation. The value must be an integer.

The saxon:character-representation attribute

This attribute allows greater control over how non-ASCII characters will be represented on output.

With method="xml", two values are supported: "decimal" and "hex". These control whether numeric character references are output in decimal or hexadecimal when the character is not available in the selected encoding.

With 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 "native", "entity", "decimal", or "hex". The second string defines how characters outside the encoding will be represented, the values being "entity", "decimal", or "hex". Here "native" means output the character as itself; "entity" means use a defined entity reference (such as "&eacute;") if known; "decimal" and "hex" refer to numeric character references. For example "entity;decimal" (the default) means that with encoding="iso-8859-1", characters in the range 160-255 will be represented using standard HTML entity references, while Unicode characters above 255 will be represented as decimal character references.

The saxon:byte-order-mark attribute

This has been replaced (since Saxon 8.2) with the standard serialization attribute `byte-order-mark="yes|no"`.

The saxon:next-in-chain attribute

The `saxon:next-in-chain` attribute (XSLT-only) is 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. method, cdata-section-elements, etc) will have no effect. The output of the second stylesheet will be directed to the destination that would have been used for the first stylesheet if no `saxon:next-in-chain` attribute were not present.

The saxon:require-well-formed attribute

The attribute `saxon:require-well-formed` is available, with values "yes" or "no". The default is "no". If the value is set to "yes", and a user-written `ContentHandler` is supplied to receive the results of the transformation, then Saxon will report an error rather than sending a non-well-formed stream of SAX events to the `ContentHandler`. This attribute is useful when the output of the stylesheet is sent to a component (for example an XSL-FO rendering engine) that is not designed to accept non-well-formed XML result trees.

Note also that namespace undeclarations of the form `xmlns:p=""` (as permitted by XML Namespaces 1.1) are passed to the `startPrefixMapping()` method of a user-defined `ContentHandler` only if `undeclare-namespaces="yes"` is specified on `xsl:output`.

User defined attributes

Any number of user-defined attributes may be defined on `xsl:output`. These attributes must have names in a non-null namespace, which must not be either the XSLT or the Saxon namespace. These attributes are interpreted as attribute value templates. The value of the attribute is inserted into the Properties object made available to the Emitter handling the output; they will be ignored by the standard output methods, but can supply arbitrary information to a user-defined output method. The name of the property will be the expanded name of the attribute in JAXP format, for example "{http://my-namespace/uri}local-name", and the value will be the value as given, after evaluation as an attribute value template.

Expand | Next