<!-- Шаблоны преобразования first -->
<xsl:template match="a" mode="first">
<b>
<xsl:apply-templates select="@*|node()" mode="first"/>
</b>
</xsl:template>
<xsl:template match="@*|node()" mode="first">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="first"/>
</xsl:copy>
</xsl:template>
<!-- Шаблоны преобразования second -->
<xsl:template match="@*|node()" mode="second">
<xsl:copy>
<xsl:apply-templates select="@*|node()" mode="second"/>
</xsl:copy>
</xsl:template>
<xsl:template match="b" mode="second">
<c>
<xsl:apply-templates select="@*|node()" mode="second"/>
</c>
</xsl:template>
<!-- Основное преобразование -->
<xsl:template match="/">
<!-- Присваиваем переменной а корень входящего документа -->
<xsl:variable name="a" select="/"/>
<!-- Выводим переменную a -->
<xsl:comment> a: </xsl:comment>
<xsl:copy-of select="$a"/>
<!-- Присваиваем переменной b результат обработки переменной a -->