In XSLT, error XTDE1480 makes it an error to call xsl:result-document while evaluating a user-defined function. This error is not always detected. In particular
(a) it is not detected when the function is evaluated in push mode, which happens when the result is written directly to the result tree - for example, when the function call forms the body of the select expression in an xsl:sequence instruction
(b) it is not detected if the function call is inlined
(c) it is not detected if the effect of calling the function can be statically inferred
A patch to fix (a) is being placed in Subversion. A fix for (b) will be made in the next release. (c) is not a bug, on the principle that a processor is not required to do extra work at run-time merely to detect dynamic errors.