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

Re: Translating character entities for plain text outp

Subject: Re: Translating character entities for plain text output
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 17 Jul 2002 18:47:28 +0100
character entities translate
> I can get some funny glyphs (like  for &nbsp;)
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(.'&#160;',' ')

> <!ENTITY mdash " &#38 #x2014;">.
  I assume that space is really a ; other wise it isn't well formed
you could more easily write that as
<!ENTITY mdash " &#x2014;">

If you want that to end up as - you need

translate(.'&#160;','-')

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(., '&#xA;&#xD;', ' ')"/> 

there won't be any &#xD; 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(., '&#xA;&#xD;&#160;', '  ')"/> 

but that would change 10 to space, 13 to space and 160 to nothing.
You want

 <xsl:value-of select="translate(., '&#xA;&#160;', '  ')"/> 
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.