About the Examples


Each example is located in a separate directory beneath the examples directory:

ddxq_install_directory/examples/name_of_example

For example:

ddxq5_0/examples/xqjexecute

Each example directory contains the following files:

The following examples are provided with the product:

For information about how to use each of these examples, see the following sections.

CustomDocumentURIResolver

From the CustomURIResolver directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is the XQuery file you want to execute. If you do not specify a query file name, the XQuery file in the CustomURIResolver directory is executed. Optionally, you can write your own query, save it to a file, and execute that XQuery file by entering the file name as the argument to run.bat or run.sh.

This example returns an XML document that contains a top-level directory element and a child element named file that represents each XML file found in the specified directory. The file element has a size attribute with a value of the file size in bytes, and the value of the file element is the name of the XML file. For example:

<directory> 
  <file size="10000">one.xml</file> 
  <file size="15550">two.xml</file> 
</directory> 

The resulting XML structure can be used in other XQuery expressions, as shown in the query of this example.

ExternalFunctions

From the ExternalFunctions directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is one of the following query files in the ExternalFunctions directory:

If you do not specify an XQuery file in the command line, a prompt appears asking you to enter a number that corresponds to the XQuery file you want to execute.

The result of the query is written to standard output.

ExternalVariables

From the ExternalVariables directory, enter the following command line to execute the example:

Windows:

run.bat 

UNIX:

run.sh 

A prompt appears asking you to enter one of the following numbers that correspond to the type of external variable you want to execute:

1 - Bind an xs:int external variable 
2 - Bind an xs:string external variable 
3 - Bind a DOM node to an external variable 
4 - Bind an XQItem to an external variable 
5 - Bind an XQSequence to an external variable 

JNDIDataSource

Before using this example, you must have a JNDI provider on your machine. If you do not have one, you can download one from:

http://javashoplm.sun.com/ECom/docs/
Welcome.jsp?StoreId=22&PartDetailId=7110-jndi-1.2.1-oth-JPR&SiteId=JSC&TransactionId=noreg

You must place the providerutil.jar and fscontext.jar files in your CLASSPATH. You can edit the setenv.bat (Windows) or setenv.sh (UNIX/Linux) files to do this.

From the JNDIDataSource directory, enter the following command line to execute the example:

Windows:

run.bat 

UNIX:

run.sh 

RDBMSUpdate

From the RDBMSUpdate directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is one of the following query files in the RDBMSUpdate directory:

If you do not specify a query file name, a prompt appears asking you to enter the number that corresponds to the XQuery file you want to use:

1 - insert-holdings.xq 
2 - update-holdings.xq 
3 - delete-holdings.xq  
4 - update-holdings-from-xml.xq 
5 - update-function.xq 
6 - shredding-xml.xq 

Optionally, you can write your own query, save it to a file, and execute that XQuery file by entering the file name as the argument to run.bat or run.sh.

ResultRetrieval

From the ResultRetrieval directory, enter the following command line to execute the example:

Windows:

run.bat 

UNIX:

run.sh 

A prompt appears asking you to enter one of the following numbers that correspond to the type of retrieval method you want to use:

1 - SAX 
2 - STAX 
3 - DOM 

The results of the retrieval method are displayed in the standard output.

UpdateFacility

From the UpdateFacility directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is one of the following query files in the UpdateFacility directory:

If you do not specify a query file name, a prompt appears asking you to enter the number that corresponds to the XQuery file you want to use:

1 - rename-nodes.xq 
2 - change-values.xq 
3 - insert-nodes.xq 
4 - transform-change-values.xq 
5 - transfor-insert-nodes.xq 

Optionally, you can write your own query, save it to a file, and execute that XQuery file by entering the file name as the argument to run.bat or run.sh.

XMLQuery

From the XMLQuery directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is one of the following query files in the XMLQuery directory:

If you do not specify a query file name, a prompt appears asking you to enter the number that corresponds to the XQuery file you want to use:

1 - query-initial-context.xq 
2 - query-doc-function.xq 
3 - query-external-variable.xq 
4 - query-directory.xq 
5 - query-pipeline-1.xq 

Optionally, you can write your own query, save it to a file, and execute that XQuery file by entering the file name as the argument to run.bat or run.sh.

XQJExecute

From the XQJExecute directory, enter the following command line to execute the example:

Windows:

run.bat [xquery_file] 

UNIX:

run.sh [xquery_file] 

where xquery_file is one of the following query files in the XQJExecute directory:

If you do not specify an XQuery file in the command line, a prompt appears asking you to enter a number that corresponds to the XQuery file you want to execute. Or, you can enter the number "9" and then type in the text of your own query, which will be executed.