I am trying to run an XQuery file using Saxon. I keep getting this error when the code execute. The funny thing is the XQ works fine when i debug it as a standalone file in XMLSpy. When i deploy it and run my application, it throws the following exception:
Error reading datasource: XQuery Processor Exception: Exception while calling Saxon: org.xml.sax.SAXParseException: : XML-20201: (Fatal Error) Expected name instead of :.; SystemID: ; Line#: 8; Column#: -1; Cause: : XML-20201: (Fatal Error) Expected name instead of :.
I am not able to figure out where the error happens and what i can do to fix it. My only guess is the the input XMLs to XQuery might be an issue. But i am not sure which line in the XQuery is failing. As line 8 is commented line!
Is there any way to narrow it down, where the error is coming from?
What API are you using for running the query, and how do you load the source document?
It looks as if an error is being reported to Saxon by the XML parser for the source document. The line #8 is a reference to a line number in the source document. From the form of the parser exception, I would suspect that you are using a pull parser, perhaps via the XQJ API. (But you've told us so little that this is pure speculation.)
First check that the XML source document is actually well-formed. If it is, then this could be a problem with the pull parser: some of the StAX parsers I have tested with have been very unreliable, and the only one I can recommend is Woodstox.