xsl:result-document instruction is used capture an output tree from the XSLT transformation
and to determine where this tree should be added to the HTML of the rendered page.
The recommended design approach with Saxon-CE is not to render the entire HTML page from the stylesheet, but rather to generate fragments of HTML which can be inserted into the static skeleton of the page at the appropriate places.
<xsl:result-document href="#abcd"> causes the result tree to be
written as the last (or only) child of the HTML element with a given ID value.
can be used to select the target element. The result tree will be appended as a child of the
first selected element. Relative XPaths like
../h1 may be used if the current node
is set and is a member of the host HTML document.
Considerations when selecting the HTML target node:
All HTML elements and attributes are considered to have lower-case names
For elements in a namespace such as XHTML or SVG, ensure the appropriate namespace context is provided
Mandatory nodes such as
tableare implicit within the DOM, even when not added explicitly
href supplied does not match an existing element in the HTML page, the
xsl:result-document instruction is ignored and the transform will continue to
completion. In this case, Saxon-CE (debug version only) sends a warning message to the
development console with information about the failed match.
method attribute may be one of
ixsl:append-content (the default)
ixsl:replace-content. This indicates whether the new content should replace all
existing content in the selected element, or should be appended after existing content.
xsl:result-document instruction is evaluated, the HTML page is not updated immediately.
Instead, the result documents are added to a pending update list, which is used to modify the HTML page when
all processing is complete. The stylesheet therefore gets a static view of the HTML page, which
is not affected by changes made during that processing phase. Of course, when a new
transformation starts in response to user input, the effects of the previous phase are
When HTML page changes are required that only affect attributes, the extension instructions
xsl:remove-attribute can be used. See Extension Instructions for more detail.
The effect of these instructions, like
xsl:result-document, is also deferred
until the transformation is complete.