Re: [xsl] Dealing With Unwanted Characters

Subject: Re: [xsl] Dealing With Unwanted Characters
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 25 Jul 2001 09:59:20 +0100
Hi Bryan,

> I am handling an XML file that has a number of '£' characters within
> the text nodes. These are causing difficulties when I try to display
> the output in IE 5 - a message appears telling me that these
> characters are invalid. Anything I can do in my xsl to overcome
> this, or do I need to do something (if so, what?) to my xml (apart
> from removing the '£' from the source xml, which I have no power to
> do)?

The reason that IE is objecting is because the character encoding
that's been used to save the document is not the same as the character
encoding declared (or left undeclared) for the document. Given that it
contains '£' signs, most likely you have an XML declaration like:

  <?xml version="1.0"?>

which indicates that the file is saved in UTF-8, whereas it's actually
been saved in ISO-8859-1. You need to either change the XML
declaration to:

  <?xml version="1.0" encoding="ISO-8859-1"?>

or go through the document and change all the '£' characters into the
character reference &#163;.

If you cannot change the source document at all, then you're pretty
much stuck. XSLT can only work with well-formed XML documents, and a
document that contains '£' characters without the proper encoding is
not a well-formed XML document.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread