xsl:result-document inside of an xsl:function?
Added by Martin Honnen 1 day ago
https://www.w3.org/TR/xslt-30/#result-document-restrictions says (emphasis added by me):
There are restrictions on the use of the xsl:result-document instruction, designed to ensure that the results are fully interoperable even when processors optimize the sequence in which instructions are evaluated. Informally, the restriction is that the xsl:result-document instruction can only be used while writing a final result tree, not while writing to a temporary tree or a sequence. This restriction is defined formally as follows.
[Definition: Each instruction in the stylesheet is evaluated in one of two possible output states: final output state or temporary output state ].
[Definition: The first of the two output states is called final output state. This state applies when instructions are writing to a final result tree.]
[Definition: The second of the two output states is called temporary output state. This state applies when instructions are writing to a temporary tree or any other non-final destination.]
The instructions in the initial named template are evaluated in final output state. An instruction is evaluated in the same output state as its calling instruction, except that xsl:variable, xsl:param, xsl:with-param, xsl:function, xsl:key, xsl:sort, xsl:accumulator-rule, and xsl:merge-key always evaluate the instructions in their contained sequence constructor in temporary output state .
[ERR XTDE1480] It is a dynamic error to evaluate the xsl:result-document instruction in temporary output state .
However, when reading through the SaxonJS 3 documentation about many ixsl extension functions like https://www.saxonica.com/saxonjs/documentation3/index.html#!ixsl-extension/functions/doc, I find usages like
Asynchronously fetch an XML document, proceeding when the document is available:
<xsl:template name="xsl:initial-template"> <ixsl:promise select="ixsl:doc($href)" on-completion="f:go#1"/> </xsl:template> <xsl:function name="f:go" ixsl:updating="true"> <xsl:param name="doc" as="document-node()"/> <xsl:result-document href="{$output-file}"> <xsl:copy-of select="$doc"/> </xsl:result-document> </xsl:function>
Is the ixsl:updating
decisive here to allow the use of xsl:result-document
in an xsl:function
with SaxonJS 3?
Replies (1)
RE: xsl:result-document inside of an xsl:function? - Added by Michael Kay about 11 hours ago
Yes, that's correct. As stated in various places in the documentation:
A common requirement is for the handler function to have updating side-effects, for example by calling
xsl:result-document
. For this to be allowed, the function must be declared withixsl:updating="yes"
.
Please register to reply