[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Character substitution

Subject: Re: [xsl] Character substitution
From: Jim Fuller <jim.fuller@xxxxxxxxxxxxxx>
Date: Mon, 10 Jan 2005 10:48:38 -0500

Sven Waibel wrote:

i looked at the FAQ and i found the solution to replace characters. But the variable text is empty resp. match="text()"
and then the . returns nothing.
How can i substitute the $ character?

how is the euro character represented in your document ?

is it an entity (e.g. I think its numeric entity is &128;) if so u might have to;

- try using numeric entity for replacement
- make sure your xml encoding is iso-8859-1 (or UTF-8)

you can take a look at an xsl template that has been tested over time at exslt.org

gl, Jim Fuller

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

<xsl:template name="change">
   <xsl:param name="text"/>
	<xsl:value-of select="$text"/>
		<xsl:when test="contains($text, '$')">
			<xsl:value-of select="substring-before($text, '$')"/>
		   	<xsl:call-template name="change">
			    <xsl:with-param name="text" select="substring-after($text,'$')"/>
			<xsl:value-of select="$text"/>


my xml:
<?xml version="1.0" encoding="ISO-8859-15"?>
        <creation date="2005-01-10" timestamp="1105349670236" user="sven" login="sven" />
    <test-t id="35" >

Current Thread