This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Using accented characters in XML
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Using accented characters in XML
- From: Mike Brown <mike at skew dot org>
- Date: Fri, 18 May 2001 15:48:24 -0600 (MDT)
- Reply-To: xsl-list at lists dot mulberrytech dot com
Alex Black wrote:
> Am I correct in assuming that were he to include that encoding declaration,
> along with the accented É - the xslt processor would not have a problem, but
> the _output_ would still contain the original character, _not_ its encoded
> counterpart?
No, you're not correct in assuming that.
The encoding declaration has no bearing on output / serialization of the
result tree. It is merely saying that the bytes in the XML document
represent characters according to a particular character map.
The "raw" accented É is the single byte 0xC9 in iso-8859-1, but in utf-8 is
the pair of bytes 0xC3 0x89. Whatever was used to produce the XML file put
byte 0xC9 in there.
The XML parser, when reading these bytes, if it knows that the encoding is
iso-8859-1, reports to the application (the XSLT processor) that there is
this run of character data consisting of the following:
Unicode character U-000000C9 (Latin capital letter E with acute)
Unicode character U-00000064 (Latin small letter d)
Unicode character U-00000069 (Latin small letter i)
Unicode character U-00000074 (Latin small letter t)
Unicode character U-00000065 (Latin small letter e)
Unicode character U-0000007A (Latin small letter z)
If the document contained 0xC3 0x89 instead of 0xC9, and left out the
encoding declaration or the encoding declaration said utf-8, it would report
the same sequence of characters.
If the document contained a character reference É or É instead of
the raw accented character, the parser would still report the same thing.
Even though the bytes for the 6 characters & # 2 0 1 ; are in the file, it
will tell the application that it only saw Unicode character C9.
> i.e. if he were going to html, it would look like this:
> <b>Éditez</b> (which isn't correct)
There's nothing incorrect about that. The HTML document should declare its
encoding, to be safe:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> not
>
> <b>Éditez</b>
> or
> <b>Éditez</b>
This is entirely up to the serializer in the XSLT processor's implementation
of the html output method. Within the XSLT/XPath tree model there are no
entity or character references, only the Unicode characters reported by the
parser. The result tree that you construct during an XSLT transformation
only contains the one character that is Latin capital letter E with acute.
The XSLT processor may serialize that with raw bytes or may use the bytes
that form a character or entity reference instead.
- Mike
_____________________________________________________________________________
mike j. brown, software engineer at | xml/xslt: http://skew.org/xml/
webb.net in denver, colorado, USA | personal: http://hyperreal.org/~mike/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list