AW: [xsl] replaceing chars with entities

Subject: AW: [xsl] replaceing chars with entities
From: "Szabo, Patrick \(LNG-VIE\)" <patrick.szabo@xxxxxxxxxxxxx>
Date: Wed, 2 Jun 2010 14:26:22 +0200
works like a charm !

thx a lot !

greetings


Patrick Szabo
 XSLT-Entwickler

Tel.: +43 (1) 534 52 - 1573
Fax: +43 (1) 534 52 - 146

Patrick.Szabo@xxxxxxxxxxxxx

LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
http://www.lexisnexis.at/

-----UrsprC<ngliche Nachricht-----

Von: Martin Honnen [mailto:Martin.Honnen@xxxxxx]
Gesendet: Mittwoch, 02. Juni 2010 14:18
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re: [xsl] replaceing chars with entities

Szabo, Patrick (LNG-VIE) wrote:

> I'm using XSLT 2.0 and Saxon 9
> Im trying to replace certain chars with entities like this:
>
> <xsl:template match="text()">
> 	<xsl:value-of select="replace(replace(replace(replace(., 'C', '&#223;',
'i'), 'C$', '&#228;', 'i'), 'C<', '&#252;', 'i'), 'C6', '&#246;', 'i')"
disable-output-escaping="yes"/>
> </xsl:template>
>
> It just doesn't seem to to anything. If i do this:
>
> <xsl:template match="text()"/>
>
> all the text from the document is gone so the template matches...it just
doesn't replace anything :-/
>
> Any ideas ?!

Well in an XML document like an XSLT stylesheet
   '&#223;'
is the same as writing
   'C'
so you are replacing each character with itself with your code.
If you want to replace certain characters with numeric character
references in the serialized output of an XSLT 2.0 transformation then
you can achieve that with a character map:
http://www.w3.org/TR/xslt20/#character-maps

   <xsl:character-map name="map1">
     <xsl:output-character character="C" string="&amp;#223;"/>
     ...
   </xsl:character-map>

   <xsl:output use-character-maps="map1"/>

--

	Martin Honnen
	http://msmvps.com/blogs/martin_honnen/

Current Thread