# saxon:serialize()

serialize(node, format)

This function takes two arguments: the first is a node (generally a document or element node) to be serialized. When called within an XSLT stylesheet, the second argument is the name of an `xsl:output` element in the stylesheet. In non-XSLT environments, the second argument is the name of the output method (xml, html, xhtml, text), and the other serialization parameters are defaulted. The second argument must be known at compile time (it will typically be supplied as a string literal.) The function serializes the specified document, or the subtree rooted at the specified element, according to the parameters specified, and returns the serialized document as a string.

This function is useful where the XSLT stylesheet wants to manipulate the serialized output, for example by embedding it as CDATA inside another XML document, or prefixing it with a DOCTYPE declaration, or inserting it into a non-XML output file.

Expand | Up Next