[Home] [By Thread] [By Date] [Recent Entries]
I was able to get one step closer to my goal...
Here is my replace function and the recursive call: <xsl:template name="replace-string"> <xsl:param name="text"/> <xsl:param name="from"/> <xsl:param name="to"/> <xsl:choose> <xsl:when test="contains($text, $from)"> <xsl:variable name="before" select="substring-before($text, $from)"/> <xsl:variable name="after" select="substring-after($text, $from)"/> <xsl:variable name="prefix" select="concat($before, $to)"/> <xsl:value-of select="$before"/> <xsl:copy-of select="$to"/> <xsl:call-template name="replace-string"> <xsl:with-param name="text" select="$after"/> <xsl:with-param name="from" select="$from"/> <xsl:with-param name="to" select="$to"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:param name="returnString"> <xsl:call-template name="replace-string"> <xsl:with-param name="text" select="$text"/> <xsl:with-param name="from" select="$changes/change[$count]/text" /> <xsl:with-param name="to" select="$changes/change[$count]/link" /> </xsl:call-template> </xsl:param> <xsl:if test="$count > 1"> <xsl:call-template name="replace-strings"> <xsl:with-param name="text" select="$returnString" /> <xsl:with-param name="changes" select="$changes" /> <xsl:with-param name="count" select="$count - 1" /> </xsl:call-template> </xsl:if> <xsl:if test="$count = 1"> <xsl:copy-of select="$returnString" /> </xsl:if> </xsl:template> As you can see, I have my changes saved as text and link. By changing two VALUE-OF statemetns by COPY-OF statatements I was able to get the last change to hold the anchor, but all other previous replacements dissapear. Is there a way to send a parameter to a function containing the anchor values? I think that there is where I loose the anchors, since I have to resend the variables, the copy-of does not stick and the anchor information is lost. I tried using <xsl:with-param ...> <xsl:copy-of select ...> </xsl:with-param> but that doesn't seem to work either. From: "Ignacio Garcia del Campo" <igarc001@xxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Multiple String Replacements [with a twist] Date: Tue, 27 Mar 2007 14:56:11 -0400
|

Cart



