gudii9
asked on
xquery error
hi,
while executing below xquery
for $x in doc("Books.xml")/books/boo k
return if{$x/@category="XML")then <XMLBOOK>{ data($x/ti tle)}</XML BOOK>
else <NONXML>{data($x/title)}</ NONXML>
on below xml
Syntax error on line 2 at column 9 of file:/C:/Users/sg/gpJava/u d/xsl_xpat h_jquery/X Query/Book s2.xqy near {....xml")/books/book return if...}
XPST0003: Unrecognized node constructor if{}
Static error(s) in query
how to fix it
please advise
while executing below xquery
for $x in doc("Books.xml")/books/boo
return if{$x/@category="XML")then
else <NONXML>{data($x/title)}</
on below xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
<book category="JAVA">
<title>Master Core Java</title>
<author>JG</author>
<year>2015</year>
<price>50</price>
</book>
<book category="DOTNET">
<title>Get Certified in .Net</title>
<author>BG</author>
<year>2016</year>
<price>60</price>
</book>
<book category="XML">
<title lang="en">XML and XML Schema Definition in easy steps</title>
<author>BT</author>
<year>2014</year>
<price>20</price>
</book>
<book category="XML">
<title lang="en">XSLT XPATH and XQuery Fundamentals</title>
<author>BT</author>
<year>2016</year>
<price>30</price>
</book>
</books>
getting below errorSyntax error on line 2 at column 9 of file:/C:/Users/sg/gpJava/u
XPST0003: Unrecognized node constructor if{}
Static error(s) in query
how to fix it
please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
for $x in doc("Books.xml")/books/boo k
return if($x/@category="XML")then <XMLBOOK>{ data($x/ti tle)}</XML BOOK>
else <NONXML>{data($x/title)}</ NONXML>
it worked as above
in eclipse how to create xpy file??(File -->New -->Other has only option to create xml though..do i need separate plug in for this?)
As of now i just imported unzipped folder as existinng project.
then i clicked on the xqy file and run --->run as--->run configuration
there in main
i searched on Query selected
net.sf.saxon.Query
(not sure why it showed same entries two times any way i selected one of them)
In arguments i gave Books2.xpy the same xquery file name i am runing
when i apply and run console gave the result of the filtered data
<?xml version="1.0" encoding="UTF-8"?><NONXML> Master Core Java</NONXML><NONXML>Get Certified in .Net</NONXML><XMLBOOK>XML and XML Schema Definition in easy steps</XMLBOOK><XMLBOOK>XS LT XPATH and XQuery Fundamentals</XMLBOOK>
xquery1.png
xquery2.png
return if($x/@category="XML")then
else <NONXML>{data($x/title)}</
it worked as above
in eclipse how to create xpy file??(File -->New -->Other has only option to create xml though..do i need separate plug in for this?)
As of now i just imported unzipped folder as existinng project.
then i clicked on the xqy file and run --->run as--->run configuration
there in main
i searched on Query selected
net.sf.saxon.Query
(not sure why it showed same entries two times any way i selected one of them)
In arguments i gave Books2.xpy the same xquery file name i am runing
when i apply and run console gave the result of the filtered data
<?xml version="1.0" encoding="UTF-8"?><NONXML>
xquery1.png
xquery2.png
If you mean create an XQuery file in Eclipse, then yes you need a plugin.
The details are here https://wiki.eclipse.org/New_Eclipse_Plugin_for_XQuery
I have no idea what an "xpy" file is?
The details are here https://wiki.eclipse.org/New_Eclipse_Plugin_for_XQuery
I have no idea what an "xpy" file is?
ASKER
I have no idea what an "xpy" file is?i mean xqy which is short cut for xquery
what is the name of the plug in to search on eclipse market place? please advise
Sorry, but it beats me how one can abbreviate XQuery in a way that a "p" turns up in the string.
All the information you need for an XQuery Plug-in for Eclipse is in the link I gave you.
All the information you need for an XQuery Plug-in for Eclipse is in the link I gave you.
ASKER
i need to try on personal laptop
Ok, so install Eclipse on the LapTop, follow the link and download the plugin.
ID: 42371199 confirms the answer provided to the question.
ASKER