Project

Profile

Help

XQuery encoding='UTF-8' error

Added by Anonymous over 17 years ago

Legacy ID: #3893926 Legacy Poster: ambi (ambika_se)

hi guys I'm using Saxon8 for doing xquery in my java application. everything is working fine except for one case i'm getting a very strange error which is XPST0003: XQuery syntax error in #...rsion='1.0' encoding='UTF-8'?>#: A processing instruction must not be named 'xml' in any combination of upper and lower case My XML is perfectly fine. I run query separtely in some editor then there is no problem but if i'm using it in java application Saxon is giving me this error. If anyone have some clue about this then please tell me. I'm struck at this point


Replies (7)

Please register to reply

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894365 Legacy Poster: Michael Kay (mhkay)

It looks as if your query contains an XML declaration (<?xml....?>), which would make it an invalid query. Either there really is an XML declaration in your query, in which case you should remove it, or you have submitted an XML document to an interface where a query was expected.

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894372 Legacy Poster: ambi (ambika_se)

THE XML looks like the following ::: <?xml version="1.0" encoding="UTF-8" ?> <h:html xmlns:xdc="http://www.xml.com/books" xmlns:h="http://www.w3.org/HTML/1998/html4"> <h:head><h:title>Book Review</h:title></h:head> <h:body> <xdc:bookreview> <xdc:title>XML: A Primer</xdc:title> <h:table> <h:tr align="center"> <h:td>Author</h:td><h:td>Price</h:td> <h:td>Pages</h:td><h:td>Date</h:td></h:tr> <h:tr align="left"> <h:td><xdc:author>Simon St. Laurent</xdc:author></h:td> <h:td><xdc:price>31.98</xdc:price></h:td> <h:td><xdc:pages>352</xdc:pages></h:td> <h:td><xdc:date>1998/01</xdc:date></h:td> </h:tr> </h:table> </xdc:bookreview> </h:body> </h:html> and in just retriving the title i'm getting this strange error

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894383 Legacy Poster: Michael Kay (mhkay)

The message is complaining about your query, not about the XML.

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894404 Legacy Poster: ambi (ambika_se)

declare namespace xdc="http://www.xml.com/books"; declare namespace h="http://www.w3.org/HTML/1998/html4"; for $x in doc("file:///C:/TRY1.xml")//h:title return $x IF i'm storign this XML in a file then its fine. there is no problem But as per the req of my java program i have to stor e it in a string variable and there problem comes in so if i make XML a string and store in a string variable 'xmlTry' and query looks as "declare namespace xdc='http://www.xml.com/books';" + "declare namespace h='http://www.w3.org/HTML/1998/html4';" + "for $x in"+xml+" //h:title" + " return $x"; and here i get the same error

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894877 Legacy Poster: ambi (ambika_se)

no body has any idea abot my problem? Please any hint whats wrong?

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894893 Legacy Poster: Michael Kay (mhkay)

I have told you what's wrong. Your application is supplying a query that contains an XML declaration, and this isn't a valid query. I can't actually prove that's the case because you haven't shown your application code, but the evidence is pretty clear.

RE: XQuery encoding='UTF-8' error - Added by Anonymous over 17 years ago

Legacy ID: #3894907 Legacy Poster: Sudarshan Murthy (smurthy)

What is the value of the variable 'xml' in your last two lines of the Java code? + "for $x in"+xml+" //h:title" + " return $x";

    (1-7/7)

    Please register to reply