xsl-list
[Top] [All Lists]

Re: [xsl] CDATA and Named Entities to ASCII

2007-11-30 15:56:28
At 2007-11-30 22:51 +0000, Mark Anderson wrote:
I need to transform some XML to ASCII text.

However, the XML contains named entities - e.g. <a>this &amp; that</a>, and may contain CDATA - e.g. CDATA[This & That]]

Is there a way to transform the above to 'this & that'

<xsl:output method="text"/> will serialize your result tree as simple text without escaping markup-sensitive characters.

In your result tree all elements and attributes are ignored and all PCDATA is serialized to the output.

Construct your result tree as you would for any HTML or XML result ... that bit doesn't change ... putting out simple text is just a serialization issue.

Note that if you really need US ASCII 7-bit, then you would need:

  <xsl:output method="text" encoding="US-ASCII"/>

Typically for 8-bit text I use the Latin-1 character set:

  <xsl:output method="text" encoding="ISO-8859-1"/>

The default is UTF-8, a hybrid 7-bit/8-bit encoding.

I hope this helps.

. . . . . . . . Ken


--
Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>