Using SaxonHE 9.7/XPath-2.0
Why is this identity template returning a "Cannot write more than one result document to the same URI" when it's output is sent to a file? Without xsl:result-document
it sends it to the standard out as expected.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="@*|node()">
<xsl:result-document href="Output.xml">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
Use
<xsl:template match="/">
<xsl:result-document href="Output.xml">
<xsl:apply-templates/>
</xsl:result-document>
</xsl:template>
plus the normal identity transformation template, that way the output created by the stylesheet goes to Output.xml
. Your current code matches any node and for each matched node tries to open the same file, that is not allowed.