Re: [xsl] Replacing all Occurences of a String

Subject: Re: [xsl] Replacing all Occurences of a String
From: "cutlass" <cutlass@xxxxxxxxxxx>
Date: Thu, 30 Aug 2001 14:37:20 +0100
huh ?

try out this template here;

http://www.exslt.org/str/functions/replace/index.html

though u will be passing params, but of course u could recurse calling this
named template etc...

u could also use many of the date/time templates here, or at other places
that make facilities for delivering in different languages.

good luck, jim fuller

----- Original Message -----
From: "Roger" <roger@xxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, August 30, 2001 2:31 PM
Subject: [xsl] Replacing all Occurences of a String


> Hi there
> I want to replace the english months with the german months. It is
possible
> that the elements <sfzRelease/> and <sfzProdjahr/> have several months,
like
> this:
>
> <sfzRelease>January, February 2001</sfzRelease>
>
> I want at the end:
>
> <sfzRelease>Januar, Februar 2001</sfzRelease>
>
> I took Michael Kay's replace.xsl Stylesheet (Replacing all Occurences of a
> String). But I don't want to give it the parameters in the stylesheet
> itself. I made a xsl:choose with the parameters, but that isn't accepted.
> Can anyone help me with this.
> Thanx very much
> Roger
>
>
>
>
>
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <xsl:stylesheet
> version="1.O"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>
>
> <xsl:param name="replace"/>
> <xsl:param name="by"/>
>
> <xsl:choose>
> <xsl:when test="$replace='January'">
> <xsl:param name="by" select="Januar"/>
> </xsl:when>
>    <xsl:when test="$replace='February'">
> <xsl:param name="by" select="Februar"/>
> </xsl:when>
> <xsl:when test="$replace='March'">
> <xsl:param name="by" select="März"/>
> </xsl:when>
> <xsl:when test="$replace='May'">
> <xsl:param name="by" select="Mai"/>
> </xsl:when>
> <xsl:when test="$replace='June'">
> <xsl:param name="by" select="Juni"/>
> </xsl:when>
> <xsl:when test="$replace='July'">
> <xsl:param name="by" select="Juli"/>
> </xsl:when>
> <xsl:when test="$replace='October'">
> <xsl:param name="by" select="Oktober"/>
> </xsl:when>
> <xsl:when test="$replace='December'">
> <xsl:param name="by" select="Dezember"/>
> </xsl:when>
> </xsl:choose>
>
>
> <xsl:template name="do-replace">
> <xsl:param name="text"/>
> <xsl:choose>
> <xsl:when test="contains($text,$replace)">
> <xsl:value-of select="substring-before($text, $replace)"/>
> <xsl:value-of select="$by"/>
> <xsl:call-template name="do-replace">
> <xsl:with-param name="text"
> select="substring-after($text, $replace)"/>
> </xsl:call-template>
> </xsl:when>
> <xsl:otherwise>
> <xsl:value-of select="$text"/>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
> <xsl:template match="sfzRelease | sfzProdjahr">
> <xsl:copy>
> <xsl:copy-of select="@*"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
>
> <xsl:template match="text()">
> <xsl:call-template name="do-replace">
> <xsl:with-param name="text" select="."/>
> </xsl:call-template>
> </xsl:template>
>
> </xsl:stylesheet>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread