[xsl] Wrong encoding value: "Content is not allowed in prolog." ?

Subject: [xsl] Wrong encoding value: "Content is not allowed in prolog." ?
From: "Ben Stover" <bxstover@xxxxxxxxxxx>
Date: Wed, 28 Jul 2010 16:39:33 +0200
Assume I have an XML doc file which starts with:

<?xml version="1.0" encoding="UTF-16"?>
<foobar>....

But the xml doc file is NOT UTF-16 encoded but ANSI or ISO-8859-1 or whatever.
Does it matter?

I mean does an XSLT processor like Saxon (or other) view this as nice to have info but rely on the real encoding?

If this is an essential error: What kind of errors do I get when I process such an XML doc file?

Is there a pre-verify if XML doc file encoding and encoding value at the top fit together or will
there be an unpredictable error during processing?

I get weired errors like the following. Has this something to do with encoding error?

Saxon 9.1.0.7J from Saxonica
Java version 1.5.0_18
Warning: at xsl:stylesheet on line 2 column 80 of pBeautify.xsl:
  Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
Stylesheet compilation time: 391 milliseconds
Processing file:/D:/tmp/b/in.xml
Building tree for file:/D:/tmp/b/in.xml using class net.sf.saxon.tinytree.TinyBuilder
Error on line 1 column 40 of in.xml:
  SXXP0003: Error reported by XML parser: Content is not allowed in prolog.
Transformation failed: Run-time errors were reported

Ben

Current Thread