About the Examples


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

ddxq_install_directory/examples/name_of_example

For example:

ddxq3_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.

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.

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.

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 

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.

Connect

Before using this example, you must edit two source configuration files located in the Connect directory:

You must specify the correct values for the following elements in these files: url, user, and password. In addition, in the config_advanced.xml file, you must enter the correct values for the name attributes for the catalog and schema elements. See "Using a Source Configuration File" for more information about source configuration files.

From the Connect 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 corresponds to the connection method you want to use:

1 - Connect using config_basic.xml source configuration 
    file. 
2 - Connect using config_advanced.xml source configuration 
    file, this example shows the use of a table alias. 
3 - Connect using config_advanced.xml source configuration 
    file, this example shows the use of a target namespace 
    for a database table. 
4 - Connect using config_advanced.xml source configuration 
    file, this example shows how to eliminate certain table 
    columns from the SQL/XML view of the table. 
5 - Connect using config_advanced.xml source configuration 
    file, this example shows the use of a base URI. 
6 - Connects using config_advanced.xml source configuration 
    file, this example illustrates the use of  
    DataDirect Spy for XQJ. 

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.

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.

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.