[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Wrong encoding value: "Content is not allowed in

Subject: Re: Wrong encoding value: "Content is not allowed in prolog." ?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 28 Jul 2010 15:50:32 +0100
Re:  Wrong encoding value: "Content is not allowed in
On 28/07/2010 15:39, Ben Stover wrote:

This isn't really an xsl question 9even though you show a saxon error, it (as it says0 is just passing on the error from the parser.


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?

It depends. If the file is being read from the file system then this would be a fatal error. If it is being served by http and the correct encoding is specified in the http headers then the xml rec says they take precedence so technically the file is OK, although playing dangerously because if the file is ever saved and reloaded using a protocol that doesn't preserve the http header (eg saving it to a filesystem and re-reading) then it will break.



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


well the actual error message is a bit confused as to the error location but having got to the utf-16 it probably decided to read the file in utf16 in which case <?xml
would be some random content (whatever character the two bytes <? denote in utf16) that isn't allowed at the start of an xml file, hence the message.



David




Ben


________________________________________________________________________ This e-mail has been scanned for all viruses by Star. ________________________________________________________________________



________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.