The DataDirect XQuery® Editor for Eclipse is an Eclipse plugin that provides support for DataDirect XQuery® in Eclipse, a widely used Java development environment. This plugin requires a valid DataDirect XQuery® installation to work.
For information on here.
This tutorial covers the following topics:
You can use the DataDirect XQuery® Editor for Eclipse to
- Browse relational data sources to configure connections
- Write and test DataDirect XQuery® queries
- Drag and drop from data sources to help create XQuery path expressions
- View query results
- Automatically generate simple Java classes that run a query using the DataDirect XQuery® implementation of the XQuery API for Java (XQJ)
The following image shows the DataDirect XQuery® Editor Perspective in the Eclipse environment.
The DataDirect XQuery® Editor Perspective in Eclipse — Click the image to enlarge
Because this tool runs in Eclipse, it is easy to switch from the DataDirect XQuery® Editor Perspective to the Java Perspective, which is very convenient when writing Java programs that use XQuery.
The first time you try to execute an XQuery or connect to a relational database, the DataDirect XQuery® Editor prompts you to enter the location of your main DataDirect XQuery® library, ddxq.jar, as shown in the following illustration.
If you want to change the location/version of the DataDirect XQuery® runtime used by the DataDirect XQuery® Editor, you can do that at any time in the Preferences dialog box (shown in the following illustration). To display the Preferences dialog box, select Window > Preferences > DataDirect XQuery Editor.
You can also use the Preferences dialog box to
- Change settings about how errors are displayed
- Specify which external Java libraries need to be accessible when running a DataDirect XQuery inside the editor
- Change the settings used by the editor syntax coloring feature
The Database Connections Window (on the right in the following illustration — click to enlarge) lets you configure relational database connections and visualize the structure of relational databases.
Configuring Relational Data Sources — Click the image to enlarge
The XQuery code on the left (note the syntax coloring) was created by simply dragging a relational table (in this case,
booksXML) from the Database Connections Window and dropping it onto the editor canvas. When you drop the relational table, the DataDirect XQuery® Editor prompts you to choose one of the possible XQuery snippets, automatically generated to reference the table:
The DataDirect XQuery® Editor allows you to run ad-hoc queries and view the results, which can be useful during XQuery code development. Let's take a closer look at the XQuery Results window:
Query results can be displayed in two views — Tree or Text.
The Tree result viewer is a highly scalable way to browse query results; only a few result items are initially downloaded. You can fetch more results by right clicking on the More results available… line, or by clicking the Process more results button in the XQuery Results window.
The Text result viewer serializes the XQuery result as text. If the XQuery results are very large, the Text viewer will display a truncated version of the result serialization.
Once you are satisfied that your query is working as you expect, you can automatically generate a simple Java classes that runs the query using DataDirect XQuery®.