I’m trying to copy a xml document complete with attributes and nodes. The output does not contain attributes. fi.xml is the input, test.xsl does the transform (a mode is required in xsl). Thanks.
f1.xml
<test attr="val">
<subtest attr2="val2"/>
</test>
test.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="document('f1.xml')" mode="abc"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/ | @* | node()" mode="abc">
<xsl:copy>
<xsl:apply-templates mode="abc"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
output:
<?xml version="1.0" encoding="UTF-8"?><test>
<subtest/>
</test>
That stylesheet seems very odd, but try changing your
xsl:apply-templatesto: