This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Translating character entities for plain text output
- From: David Carlisle <davidc at nag dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 17 Jul 2002 18:47:28 +0100
- Subject: Re: [xsl] Translating character entities for plain text output
- References: <3906C56A7BD1F54593344C05BD1374B1053EB6A4@SUS-MA1IT01>
- Reply-to: xsl-list at lists dot mulberrytech dot com
> I can get some funny glyphs (like  for )
you have asked for your text to be utf8 encoded (or accepted that
default) a non breaking space in utf8 takes two bytes. If you
incorrectly look at teh file in a latin-1 encoded terminal the firat one
looks like an accented A.
You can look at teh file in a utf8 capable edito, or say
encodimg="iso-8859-1" on xsl:output in which case you will
get byte 160 for a non breaking space.
If you want to get a space then you need
translate(.' ',' ')
> <!ENTITY mdash " & #x2014;">.
I assume that space is really a ; other wise it isn't well formed
you could more easily write that as
<!ENTITY mdash " —">
If you want that to end up as - you need
translate(.' ','-')
if you want it to be -- then you need to use a recursive string replace
template (there's one in the faq) as transate() only can do one
character to one character.
> In the stylesheet, I've tried defining the entity in a local subset,
That only affects the use of the entity in the stylesheet.
there's not a lot of point in using entities in the stylesheet
it's normally sompler to use the character references directly.
<xsl:value-of select="translate(., '

', ' ')"/>
there won't be any 
 in the input unless they have been escaped in
spne way, all line endings appear as character 10, even if you are in
MSDOS.
peraps you tried
<xsl:value-of select="translate(., '

 ', ' ')"/>
but that would change 10 to space, 13 to space and 160 to nothing.
You want
<xsl:value-of select="translate(., '
 ', ' ')"/>
note two characters in each of the translate() strings.
that changes line ends and nbsp to spaces.
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list