This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Translating character entities for plain text output


> 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 " &#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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]