On 01/11/24 11:38 AM, "Martin v. Loewis" <martin / v.loewis.de> wrote:

> Bob Hutchison <hutch / xampl.com> writes:
> 
>>> Suppose you are processing
>>> 
>>> <?xml version="1.0" encoding="iso-8859-1"?>
>>> <foo>&#x03C0;</foo>
> [...]
>> In this case the input is not encoded as promised. The XML parser is
>> supposed to fail.
> [...]
>> In the example you have provided has an error in the XML file.
> 
> There is no error in this document. It is well-formed. The encoding
> only determines how to interpret the bytes in the document. It is no
> error whatsoever to put arbitrary character references at any place in
> the document that you like.

Section 4.3.3 of http://www.w3.org/TR/2000/REC-xml-20001006 has this to say:

"It is a fatal error when an XML processor encounters an entity with an
encoding that it is unable to process. It is a fatal error if an XML entity
is determined (via default, encoding declaration, or higher-level protocol)
to be in a certain encoding but contains octet sequences that are not legal
in that encoding. It is also a fatal error if an XML entity contains no
encoding declaration and its content is not legal UTF-8 or UTF-16."

> 
> Regards,
> Martin