xsl-list
[Top] [All Lists]

Replacing strings

2005-11-23 08:11:25
Hello,

i have a string that contains the value of CDATA field.

The string may contain following string:
"Vorbedinung"
"vorbedingung"
"VORBEDINGUNG"
and many, many other strings.

The strings should be replaced by "PRECONDITION".

I'm using following code up to now, but so i can replace just one string.

Does anybody know how to replace these strings?

Thanks
Sven

<xsl:template name="replace_precond">
        <xsl:param name="string" />
        <xsl:param name="from" select="'Vorbedingung'" />
        <xsl:param name="to" select="'PRECONDITION'" />
        <xsl:choose>
                <xsl:when test="contains($string, $from)">
                        <xsl:value-of select="substring-before($string, $from)" 
/>
                        <xsl:copy-of select="$to" />
                        <xsl:call-template name="replace_precond">
                                <xsl:with-param name="string" 
select="substring-after($string,
$from)" />
                                <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="$string" />
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>