Vitaliy
Vitaliy

Reputation: 2804

Why xsl:result-document fails inside <xsl:attribute> instruction?

I'm using Saxon-EE 9.3.0.4 for xsl transformations and found that when <xsl:result-document> is used inside <xsl:attribute> (as well as <xsl:namespace>, <xsl:processing-instruction>) instruction, processor raises XTDE1480 error - Cannot switch to a final result destination while writing a temporary tree

<xsl:attribute name="a">
    <xsl:result-document href="result.xml" > - error here
        test
    </xsl:result-document>
</xsl:attribute>

According to specification (Appendix D) permitted parents for <xsl:result-document> are:

Is this is bug in Saxon or limitations for <xsl:result-document> usage, which are not defined in specification?

Update: I believe that this is not a good idea to use <xsl:result-document> inside <xsl:attribute>, but why error happens?

Thanks

Upvotes: 0

Views: 1194

Answers (2)

Michael Kay
Michael Kay

Reputation: 163262

Update in 2018: note that the XSLT 3.0 specification relaxes the restrictions. Instructions such as xsl:attribute and xsl:comment no longer set temporary output state. Recent Saxon versions (certainly 9.8) implement the revised rules.

Upvotes: 1

Vincent Biragnet
Vincent Biragnet

Reputation: 2998

In the spec, you can read :

The instructions in the initial 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:attribute, xsl:comment, xsl:processing-instruction, xsl:namespace, xsl:value-of, xsl:function, xsl:key, xsl:sort, and xsl:message always evaluate the instructions in their contained sequence constructor in temporary output state.

The xsl:result-document write in a final tree result, and given the rule above, I understand that it is an error to try writting in a final tree result when inside the following elements

xsl:variable, xsl:param, xsl:with-param, xsl:attribute, xsl:comment, xsl:processing-instruction, xsl:namespace, xsl:value-of, xsl:function, xsl:key, xsl:sort, and xsl:message

Upvotes: 2

Related Questions