Support #4291

SXXP0003: Error reported by XML parser: Content is not allowed in prolog.

Added by Aliasger Baroodwala 8 months ago. Updated 8 months ago.

Start date:
Due date:
% Done:


Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


SXXP0003: Error reported by XML parser: Content is not allowed in prolog.

I am getting this error in the production environment while transforming from one xml to another using xslt 2.0. However, it is working fine when I run the same through development and quality assurance environment.

  1. No code change has been made to production.
  2. Using WebSphere 8.5.5 + Saxon 9 Enterprise Edition for all the 3 environments

attaching input xml file along with the xslt file for reference


Input.xml (2.31 KB) Input file Aliasger Baroodwala, 2019-08-20 17:55 Input.xml
transformer.xslt (509 KB) XSLT Transformer Aliasger Baroodwala, 2019-08-20 17:55 transformer.xslt
transformer.xslt (509 KB) XSLT Aliasger Baroodwala, 2019-08-20 21:56 transformer.xslt
TEST081919.xml (2.31 KB) Input file Aliasger Baroodwala, 2019-08-20 21:56 TEST081919.xml

Related issues

Copied from Saxon - Support #4288: SXXP0003: Error reported by XML parser: Content is not allowed in prolog. Duplicate 2019-08-20 Actions


#1 Updated by Aliasger Baroodwala 8 months ago

#2 Updated by O'Neil Delpratt 8 months ago

I wonder if the WebSphere environment is behind this problem. Is the development environment also using WebSphere?

#3 Updated by Michael Kay 8 months ago

The one thing we can say for certain is that there isn't enough information here to solve it.

As the message says, SXXP0003 is an error reported to Saxon by the XML parser. The message "Content not allowed in Prolog" is produced by Xerces under a wide variety of conditions: it basically means Xerces tried reading the XML file, looked to see if it starts with "<", and found that not to be the case. It can mean the file is empty, or there's a blank line at the start, or the file isn't XML at all, or there's an unexpected byte order mark at the start, or the parser is configured to expect a different encoding.

It's certainly nothing to do with the stylesheet. There's nothing wrong with the XML you are showing us, but it could be because, for some reason, this isn't the XML your application is actually reading. It might be useful for us to check the Java code that invokes the XSLT processor. My guess would be that it's some kind of configuration issue: unfortunately those are very hard to solve without hands-on access to the machine.

The fact that it works in one environment and not another gives one line of attack for diagnosis: work out what's different between the two environments. Check versions of Saxon and Java and in particular check what XML parser is being used. Consider instantiating the XML parser yourself in the application rather than leaving Saxon/JAXP to instantiate it (by supplying a SAXSource with an initialized XMLReader, rather than a StreamSource).

It's worth checking that it's not a multithreading issue. Common errors are (a) to reuse the JAXP Transformer object in multiple threads, and (b) to use a DOM Document in multiple threads.

#4 Updated by Michael Kay 8 months ago

I note that the file TEST081919.xml that you posted starts with the octets ef bb bf 3c 3f 78 - that is, it's UTF-8 with a byte order mark. Most modern XML parsers will accept this, but there may be older XML parsers that don't - see for example

This suggests that you might be able to make progress by either (a) changing which XML parser is used in your production environment, or (b) saving the XML file without a BOM at the start.

#5 Updated by Aliasger Baroodwala 8 months ago

Thanks very much I simply added -Dfile.encode=UTF-8 to the JVM's property on Websphere and it worked like a charm. Along with getting saxon license we got an expert to help us along !!! greatly appreciate your work.

#6 Updated by Michael Kay 8 months ago

  • Status changed from New to Closed

Thanks. I'm slightly surprised by the solution, but glad you found it. It was going to be some kind of configuration property like that.

Please register to edit this issue

Also available in: Atom PDF