XQuark Bridge - Examples of use

This directory contains examples of use for XQuark Bridge. The directory for each individual example generally contains:

Note that all the source files have been compiled using Ant (version 1.5.3). Any other build tool should work as well, but you will need to write your own build file.

The command-line examples given below assume that the XQuark Bridge command-line tool has been properly configured, as detailed in the installation guide.

Example Description
samples/xquery

This directory contains a set of XQuery files (.zql), adapted from the relational use cases specified by the W3C. Each query can be executed using the following command:

    xqbridge -q q4-xx.zql

This command will print the query results on the standard output.

The SQL instructions present in the load.sql file must have been previously executed in order to create the required relational structures and data.

samples/mapping/basic

This directory contains an example based on a purchase order schema, together with a basic mapping to store XML data in relational columns, without storing any relations between document elements.

XML data can be stored in the database using the following command:

    xqbridge -i po.map po1.xml

After this command has been executed, the database can be consulted to check that the data has been correctly inserted.

The SQL instructions present in the load.sql file must have been previously executed in order to create the required relational structures.

samples/mapping/purchaseOrder

This directory contains a more complex example based on the same purchase order schema, but using a complex mapping to store both XML data in relational columns and relations between document elements.

This example also uses user-defined generators to generate internal primary keys while storing the document content.

This example can be executed by using the following command:

    xqbridge -i po.map po1.xml

After this command has been executed, the database can be consulted to check that the data has been correctly inserted.

The SQL instructions present in the load.sql file must have been previously executed in order to create the required relational structures.

samples/mapping/references

This directory contains a mapping example showing how to use the mapping directives to implement data transcoding based on reference tables.

This example can be executed by using the following command:

    xqbridge -i product.map product.xml

After this command has been executed, the database can be consulted to check that the data has been correctly inserted.

The SQL instructions present in the load.sql file must have been previously executed in order to create the required relational structures.

samples/xdbc/querier1 This example is provided as an illustration of the use of the XML/DBC API. It creates a very simple application which reads a query from a file, executes it and prints the query results on the standard output.

The Main.java source should be adapted to your environnement. You should modify the user identifier, the user password, the connction JDBC URL of the underlying database and also the schema to be used.

After the source code has been compiled, the example can be executed using the run script:

    run <query file>
samples/xdbc/querier2 This example is provided as an illustration of the use of the XML/DBC API. It creates a very simple application which reads a query from a file, executes it and prints the query results on the standard output.

A configuration file config.xml should be updated according your environnement. You should modify the user identifier, the user password, the connction JDBC URL of the underlying database and also the schema to be use. The <catalogue> element describes the relational tables on which the XQuery requests will be processed.

After the source code has been compiled, the example can be executed using the run script:

    run <query file>
samples/xdbc/mapper This example is provided as an illustration of the use of the mapping API. It creates a very simple application which stores an XML document in the database, based on the specified mapping file.

Database access is hard-coded in the source code and will probably need to be updated for the example to run correctly.

After the source code has been compiled, the example can be executed using the runscript:

    run <map file> <xml file>
samples/xdbc/servlet This example is provided as an illustration of the use of the API within a simple servlet. It creates a simple Web application which can either store an XML document in the database, based on some predefined mapping files, or issue an XQuery and produce an XML document.

This example can be deployed as a standard Web application in the Apache Tomcat Web server. The location of the Web server deployment directory must be specified by setting the catalina.home variable in the Ant build.xml file or in the build.properties file. Database access are specified by the xdbc.user, the xdbc.password and the xdbc.url of the build.properties file

After the source code has been compiled and deployed (using the 'compile' and 'deploy' ant tasks), be sure to add your favourite DBMS JDBC driver in the lib folder under the Tomcat 'xqbridge' application folder (avoid .zip files, use .jar).

The example can be run using the following URL (assuming Tomcat is running locally in its standard configuration):

    http://localhost:8080/xqbridge

Note: You will need to execute the load.sql scripts contained in the xqbridge\WEB-INF\mappings folders in order to use the "insert document" function of the servlet.On the other hand, the generators are automatically compiled during servlet build.