Support #4291
closedSXXP0003: Error reported by XML parser: Content is not allowed in prolog.
0%
Description
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.
- No code change has been made to production.
- 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
**** URGENT - HIGH HIGH HIGH PRIORITY *****
Files
Related issues
Updated by Aliasger Baroodwala over 5 years ago
- File transformer.xslt transformer.xslt added
- File TEST081919.xml TEST081919.xml added
- Copied from Support #4288: SXXP0003: Error reported by XML parser: Content is not allowed in prolog. added
Updated by O'Neil Delpratt over 5 years ago
I wonder if the WebSphere environment is behind this problem. Is the development environment also using WebSphere?
Updated by Michael Kay over 5 years 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.
Updated by Michael Kay over 5 years 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 https://community.boomi.com/s/article/erroronline1contentisnotallowedinprolog
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.
Updated by Aliasger Baroodwala over 5 years 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.
Updated by Michael Kay over 5 years 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