1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<xsl:output method="xml"/>
<xsl:template match="/node()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="/*/*[last()]">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
<xsl:call-template name="duplicate" />
</xsl:template>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template name="duplicate">
<xsl:copy>
<xsl:for-each select="./*">
<xsl:if test="count(./*) > 0">
<xsl:call-template name="duplicate" />
</xsl:if>
<xsl:if test="count(./*) <= 0">
<xsl:copy />
</xsl:if>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet> |