xsl-list
[Top] [All Lists]

RE: character entities

2005-04-28 12:14:09

So, in the example below, I would expect the "&" to output as "&" 
because it is in the source XML file 

The & 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 & 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:

(“the <i>O'Hara</i> suit”)


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/ 



--~------------------------------------------------------------------
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>
--~--