XSLT 2.0 serializer |

## About the XSLT 2.0 serializer

The XSLT serializer is a component designed for the purpose of providing the XSLT engine with a serialization facility, but it can also be used by any other XML-processing program.

## Invoking the serializer without using XSLT

To invoke the serializer from a non-XSLT program you must follow the following steps:

1. Create a descedent of `XM_XSLT_SERIALIZER`. You will need to provide implementations for the two deferred routines `error_listener` and `encoder_factory`. See Overview for more details.
2. Create an `XM_XSLT_OUTPUT_PROPERTIES` object. The sole argument for the creation routine is designed for the use of XSLT's xsl:import declaration, to establish import precedence. It seems to me highly unlikely that you will want to use it if you are not using XSLT. Simply pass zero.
3. Call command from the Element change paragraph to set the serialization options that you want. These are explained in more detail below.
4. Set up an event stream and feed it to the serializer. This is explained in more detail below.

## Setting serialization options

I suggest you point your web browser at Serialization whilst reading this section. You might also look in `${GOBO}/library/xslt/example/serializer`.

When you create an `XM_XSLT_OUTPUT_PROPERTIES` object, the serialization options are identical to those you obtain by default from XSLT - that is, if you do not code an xsl:output declaration in an XSLT transformation. The following features are documented in terms of the attributes on xsl:output to which they correspond. In all cases it is recommended that you pass zero for the import precedence.

### Choosing the output method

- Calling `set_xml_defaults` is equivalent to xsl:output method="xml".
- Calling `set_html_defaults` is equivalent to xsl:output method="html".
- Calling `set_xhtml_defaults` is equivalent to xsl:output method="xhtml".
- Calling `set_text_defaults` is equivalent to xsl:output method="text".
- Calling `set_method` is equivalent to xsl:output method=qname-but-not-ncname. In order to do this, you have to first write your own custom serializer. See Output extensions for details.

### Generating the XML declaration

- Calling `set_byte_order_mark_required` is equivalent to xsl:output byte-order-mark="?".
- Calling `set_omit_xml_declaration` is equivalent to xsl:output omit-xml-declaration="?".
- Calling `set_version` is equivalent to xsl:output version="?".
- Calling `set_standalone` is equivalent to xsl:output standalone="?".

### Generating the Document Type Declaration

- Calling `set_doctype_public` is equivalent to xsl:output doctype-public="?".
- Calling `set_doctype_system` is equivalent to xsl:output doctype-system="?".

### Generating (X)HTML meta tags

- Calling `set_include_content_type` is equivalent to xsl:output include-content-type="?".
- Calling `set_media_type` is equivalent to xsl:output media-type="?".

### Miscellaneous

- Calling `set_normalization_form` is equivalent to xsl:output normalization-form="?".
- Calling `set_undeclare_prefixes` is equivalent to xsl:output undeclare-prefixes="?".
- Calling `set_indent` is equivalent to xsl:output indent="?".
- Calling `set_escape_uri_attributes` is equivalent to xsl:output escape-uri-attributes="?".
- Calling `set_cdata_sections` or `merge_cdata_sections` is equivalent to xsl:output cdata-section-elements="?".

## Invoking the serializer from the XSLT engine

In order to have the `XM_XSLT_TRANSFORMER` invoke the serializer, you need to pass an `XM_XSLT_TRANSFORMATION_RESULT` to the `transform` command which is created with the creation procedure named `make`. Almost all examples within Gobo use this feature.