Javatpoint Logo
Javatpoint Logo

XQuery If Then Else Statement

The XQuery If Then Else statement is used to check the validity of the passing input values.


XQuery If Then Else Example

Let's take an example to demonstrate the usage of if-then-else statement in XQuery. Take an XML file named books.xml and apply to it XQuery expression containing an if-then-else construct to retrieve the titles of those books where price is greater than 100.

XML statementM

books.xml

Xquery expression

books.xqy:


Execute XQuery against XML

Put the above three files to a same location. We put them on desktop in a folder name XQuery9. 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 If then else statement 1



Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA