Querying XML Documents
Using the Oracle XQuery engine, it is quite simple to query XML documents either interactively via the command line or programmatically.
Running in Interactive Mode
XQLPlus can be run in interactive mode in the same way as SQLPlus. In fact, where appropriate, it uses the same commands. To run XQLPlus in interactive mode, invoke the following command:
java oracle.xquery.XQLPlus
Then, an XQuery can be entered from the XQL prompt, terminated by /, or a script invoked via @exmpl. Typing help returns the following:
XQuery Command Line Tool
Enter XQuery statements followed by /;
To execute queries in a file from the XQL prompt, enter @ followed by
the <fileName>
To execute queries in a file from the shell prompt, enter
java XQLPlus <fileName>
Set command helps set environment variables:
set sqlconn default=<jdbc-connect-string>
set sqlconn <name> =<jdbc-connect-string>
set echo (ON | OFF)
set timing (ON | OFF)
set var <variable name> <value>
set print_plan (ON | OFF)
Querying XML from the Command Line
In addition to interactive mode XQLPlus can be invoked with arguments:
java oracle.xquery.XQueryContext –xqfile /private/exmp11.xql
These can be the XQuery file containing the query, an optional base URL to be used when accessing filenames inside document functions in the XQuery, and optional debug features. For example:
java oracle.xquery.XQueryContext –xqfile /private/exmp11.xql
–baseurl /private –debug
Querying XML with XQueryX
The XQueryX XML file can also be run from the XQLPlus engine via
java oracle.xquery.XQLPlus @foo.xml
or at the command-line prompt after invoking XQLPlus.