[Home] [By Thread] [By Date] [Recent Entries]
For XSLT 1.0 you can replace the for each with a recursive template as
below:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="root"> <xsl:copy><xsl:apply-templates/></xsl:copy> </xsl:template> <xsl:template match="level">
<xsl:variable name="level" select="."/>
<xsl:call-template name="processLevel">
<xsl:with-param name="states" select="states"/>
</xsl:call-template>
</xsl:template><xsl:template name="processLevel"> <xsl:param name="states"/> <xsl:if test="string-length($states)>0"> <xsl:apply-templates mode="copy"> <xsl:with-param name="state" select="substring($states, 1, 1)"/> </xsl:apply-templates> <xsl:call-template name="processLevel"> <xsl:with-param name="states" select="substring($states, 2, string-length($states))"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="node() | @*" mode="copy">
<xsl:param name="state"/>
<xsl:copy>
<xsl:apply-templates select="node() | @*" mode="copy">
<xsl:with-param name="state" select="$state"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template> <xsl:template match="elem1/text()" mode="copy">
<xsl:param name="state"/>
<xsl:value-of select="."/>
<xsl:text>_</xsl:text>
<xsl:value-of select="$state"/>
</xsl:template>
</xsl:stylesheet>Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com nick public wrote: Hi George, I appreciate very much your help. Unfortunately, the middleware that I'm using and in which the XSLT have to run, provide just XSLT version 1.0. Is it possible to adapt your solution for XSLT 1.0?
|

Cart



