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

RE: character entities

Subject: RE: character entities
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 28 Apr 2005 20:14:09 +0100
character reference templates
> So, in the example below, I would expect the "&amp;" to output as "&"
> because it is in the source XML file

The &amp; represents an ampersand; it's seen within the XSLT stylesheet as a
single character (for example, string-length() is 1); but if you serialize the
result as XML or HTML then it will be output as &amp; because that's how an
ampersand is represented in XML and HTML.

> and I would expect that
> a character
> reference created in the XSLT template would output as the reference.

You can't create character references in an XSLT template. When you write

<xsl:template match="quote">
   &#8220;<xsl:apply-templates/>&#8221;
</xsl:template>

the character references are converted by the XML parser into regular
characters. The XSLT processor doesn't know that they were originally written
as character references, any more than it does for the source document.

>
> I get this mess in place of the quotes:
>
> (C"b,Ethe <i>O'Hara</i> suitC"b,B)
>

That's not the output of the stylesheet (or even of the serializer): that's
the output of the software that you're using to display the output of the
serializer on your screen. And it's a mess because you haven't told that
software that you're asking it to display data that's encoded in UTF-8. Either
configure your display software (e.g. text editor) to display UTF-8 correctly,
or generate your output in some other encoding, such as iso-8859-1, that your
display software understands.

Michael Kay
http://www.saxonica.com/

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.