[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Replacing all Occurences of a String

Subject: Replacing all Occurences of a String
From: "Roger" <roger@xxxxxxxx>
Date: Thu, 30 Aug 2001 15:31:46 +0200
 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

<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

<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:param name="replace"/>
<xsl:param name="by"/>

			<xsl:when test="$replace='January'">
				<xsl:param name="by" select="Januar"/>
		   	<xsl:when test="$replace='February'">
				<xsl:param name="by" select="Februar"/>
			<xsl:when test="$replace='March'">
				<xsl:param name="by" select="März"/>
			<xsl:when test="$replace='May'">
				<xsl:param name="by" select="Mai"/>
			<xsl:when test="$replace='June'">
				<xsl:param name="by" select="Juni"/>
			<xsl:when test="$replace='July'">
				<xsl:param name="by" select="Juli"/>
			<xsl:when test="$replace='October'">
				<xsl:param name="by" select="Oktober"/>
			<xsl:when test="$replace='December'">
				<xsl:param name="by" select="Dezember"/>

<xsl:template name="do-replace">
	<xsl:param name="text"/>
	<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:value-of select="$text"/>

<xsl:template match="sfzRelease | sfzProdjahr">
	<xsl:copy-of select="@*"/>

<xsl:template match="text()">
	<xsl:call-template name="do-replace">
		<xsl:with-param name="text" select="."/>


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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.