XQuery SyntaxXQuery elements, attributes, and variables must be valid XML names and follow case sensitivity. XQuery Syntax Rules
ExampleLet's take an XML file 'books.xml' having the following data: XQuery Conditional ExpressionsThe "If-Then-Else" conditional statement is allowed in XQuery. XQuery statement: books.xqy How to runCreate 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. XQueryTester.java Execute XQuery against XMLPut 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. Compile: javac XQueryTester.java Execute: java XQueryTester Output: XQuery ComparisonsThere 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: Next TopicXQuery Add |