Subject: Re: [xsl] Replace Escapes From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 15 Nov 2006 09:49:13 +0000 |
I have difficulty in recursive replacement of escapes.
<xsl:variable name="replacements" select="/broadcast/ORDER_FEED/ORDER/ORDER_HEADER/*" />
<xsl:template name="replace-escapes"> <xsl:param name="string" /> <xsl:choose> <xsl:when test="contains($string, '[')"> <!-- substring before the escaped sequence --> <xsl:value-of select="substring-before($string, '[')" />
<!-- replacement for the string between the []s --> <xsl:variable name="ename" select="substring-before(substring-after($string, '['), ']')" /> <xsl:value-of select="$replacements[name() = $ename]" />
<!-- recursive call on the rest of the string --> <xsl:call-template name="replace-escapes"> <xsl:with-param name="string" select="substring-after(substring-after($string, '['), ']')"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$string" /> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:template match="broadcast"> <xsl:apply-templates select="content_vars/content/*" mode="copy" /> </xsl:template>
<xsl:template match="*" mode="copy"> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates mode="copy" /> </xsl:copy> </xsl:template>
<xsl:template match="text()" mode="copy"> <xsl:call-template name="replace-escapes"> <xsl:with-param name="string" select="." /> </xsl:call-template> </xsl:template>
Jeni -- Jeni Tennison http://www.jenitennison.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Replace Escapes, Senthilkumaravelan K | Thread | [xsl] Xalan-J 2.6 cannot find my ca, Mark Peters |
RE: [xsl] Getting unique items from, Guy | Date | [xsl] Xalan-J 2.6 cannot find my ca, Mark Peters |
Month |