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

Translating character entities for plain text output

Subject: Translating character entities for plain text output
From: "Bradford, Denis" <denisb@xxxxxxxxxxxx>
Date: Wed, 17 Jul 2002 13:17:50 -0400
docbook text output
I've found a lot of discussion in the archives about solving character
entity problems for HTML output, but not much on plain text:

Generating plain text from docbook via XSLT, I need to output a space for
&nbsp; and -- for &mdash;.  I can get some funny glyphs (like  for &nbsp;)
and various literal codes, but not the result I want. I could postprocess
the output, but I'd love to fix the style sheet.

The XML document is encoded in utf-8 and resolves these characters through
the standard docbook entity files. Specifically, <!ENTITY nbsp "&#160;"> and
<!ENTITY mdash " &#38 #x2014;">.

In the stylesheet, I've tried defining the entity in a local subset, also
html and text methods and various encodings in the xsl:output. The following
almost works:

<xsl:template match="text()">
     <xsl:if test="contains(.,'&#160;')">
         <xsl:value-of select="translate(., '&#160;', ' ')"/>
     </xsl:if>
</xsl:template>

Unfortunately, this seems to suppress another essential translation on the
same context:

     <xsl:value-of select="translate(., '&#xA;&#xD;', ' ')"/> 

I can do either, but not both.

There must be a better way...

Thanks,
Denis


 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.