[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: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 29 Jul 2010 09:42:30 +0100
Re:  Wrong encoding value: "Content is not allowed in
On 28/07/2010 15:39, Ben Stover wrote:
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?


XSLT processors don't care. They pass off the work to an XML parser. Which is why, when a failure occurs, Saxon is careful to tell you that the error comes from the XML parser, not from Saxon itself.
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

That's another way of saying: you can choose from a wide range of parsers to run with Saxon, and if you choose one that has poor error messages, that's your problem not mine. (The one I generally recommend is the Xerces parser from Apache, but the one that most people use is the Xerces-derivative contained in the Sun/Oracle JDK; Sun's main contribution was to add bugs.)

In practice "Content not allowed in prolog" is a very generic way of reporting that the parser can't make sense of the bytes at the start of the file, and an incorrect encoding is one possible reason for that failure.

Michael Kay
Saxonica

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.