XQuery elements, attributes, and variables must be valid XML names and follow case sensitivity.
XQuery Syntax Rules
Let's take an XML file 'books.xml' having the following data:
XQuery Conditional Expressions
The "If-Then-Else" conditional statement is allowed in XQuery.
How to run
Create a Java based XQuery executor program to read the books.xqy, passes it to the XQuery expression processor, and executes the expression. After that the result will be displayed.
Execute XQuery against XML
Put the above three files to a same location. We put them on desktop in a folder name XQuery6.
Compile XQueryTester.java using console. You must have JDK 1.5 or later installed on your computer and classpaths are configured.
There are two types for comparing values in XQuery.
Difference between general comparison and value comparison
It can be explained by an example. The following expression returns true if any q attributes have a value greater than 100.
The following expression returns true if there is only one q attribute returned by the expression, and its value is greater than 10. If more than one q is returned, an error occurs: