Main Page » Getting Started » Integrating Eclipse

Integrating Eclipse

This tutorial describes how to access BaseX from Eclipse via the oXygen XML Editor plugin.

The plugin offers the same features as specified in Integrating oXygen. However, the way to get there from within Eclipse is a bit different.

There are two alternatives for using BaseX in oXygen:

  • Resources in BaseX Databases can be browsed, opened and modified via WebDAV.
  • XQuery expressions can be run by the query processor of BaseX via the XQJ interface.

Note: BaseX itself is a highly compliant XQuery 4.0 processor. The XQJ interface, which is used to establish the connection between oXygen and BaseX, is specified for XQuery 1.0. We encourage you to use the XML editor integrated into the BaseX GUI to edit and query your XML data.

Preparations

  1. Download and install Eclipse. Note: The plugin officially supports Eclipse 4.5 to 4.39. Please also note that you will require an oXygen license to use the plugin.
  2. Follow the instructions in the oXygen Manual to install the plugin, e.g. via HelpInstall New Software and the update site https://www.oxygenxml.com/InstData/Editor/Eclipse/site.xml.
  3. In Eclipse, click on the oXygen icon in the upper right corner to open the plugin. The XML Project you created during the installation of the plugin should be displayed in the Navigator panel. In this example, it is called BaseXProject:

Access Database Resources

Added: Instructions for accessing database resources via WebDAV were re-added.

Preparations

  1. Download one of the complete BaseX distributions (ZIP, EXE).
  2. Start the Web Application, e.g. with the basexhttp start script (see Startup).
  3. Create a BaseX database, if necessary (see Databases).

Configuration

Note: If you have already integrated BaseX into the oXygen XML Editor itself as described in Integrating oXygen, your BaseX WebDAV connection will already be available in the plugin.
  1. In Eclipse, go to menu WindowPreferences (EclipseSettings on macOS). In the dialog, choose the oXygen XML Editor item, and then the Data Sources subitem.
  2. In the Connections panel (in the lower half of the screen), click the New button (+).
  3. Enter “BaseX WebDAV” as connection name.
  4. Select one of the WebDAV data sources (e.g. WebDAV (S)FTP) in the Data Source dropdown box.
  5. Fill in the appropriate connection details as follows:
    • Set the WebDAV URL to http://localhost:8080/webdav.
    • Set the User to admin and enter your password:
  6. Click OK to complete the connection configuration.
  7. Click Apply and Close to close the preferences dialog.
  8. If prompted, restart Eclipse to activate all changes.

You can then access your databases via the Data Source Explorer: WindowShow ViewData Source Explorer. Databases are listed as top-level folders, and the resources they contain can be opened, edited, copied, moved and deleted.

Notes

  • The credentials of a database user are requested, and its permissions decide which operations are allowed. A user with create permission is required to add or drop databases.
  • A resource that is saved directly below /webdav will create a new database, named after the file without its suffix.
  • BaseX supports WebDAV write locks. They can be requested by the plugin via PreferencesoXygen XML EditorNetwork Connection SettingsHTTP(S)/WebDAVLock WebDAV files on open. Locks are kept in main memory and will be discarded when the server is restarted.
  • See WebDAV for more details on the service and its conventions.

Perform Queries

One-Time Setup

Note: If you have already integrated BaseX into the oXygen XML Editor itself as described in Integrating oXygen, your data sources and connections will already be available in the plugin.

Configuration

  1. In Eclipse, go to menu WindowPreferences (EclipseSettings on macOS). In the dialog, choose the oXygen XML Editor item, and then the Data Sources subitem.
  2. In the Data Sources panel, add a new data source using the New button (+).
  3. Enter “BaseX” as name and select XQuery API for Java (XQJ) from the Type dropdown box.
  4. Add the following JAR files of your distribution with the Add button. The versions of the JAR files may differ:
    • basex/lib/xqj-api-1.0.jar
    • basex/lib/xqj2-0.2.0.jar
    • basex/lib/basex-xqj-13.0.jar
    • basex/BaseX.jar, if you want to use BaseX embedded
  5. Under Driver class, choose the preferred driver class:
    • Client/server communication: net.xqj.basex.BaseXXQDataSource
    • Embedded use (standalone): net.xqj.basex.local.BaseXXQDataSource
  6. Click OK

Configure Connection

  1. In the Connections section (in the lower half of the Data Sources dialog), click New (+).
  2. Enter “BaseX XQJ” as name and select “BaseX” as data source.
  3. If you use the default driver, enter the following values in the Connection Details section:
    • port: 1984
    • serverName: localhost
    • user: admin
    • password: your password
  4. Click OK to complete the connection configuration.
  5. Click Apply and Close to close the preferences dialog.
  6. If prompted, restart Eclipse to activate all changes.

Configure New Transformation Scenario

  1. In Eclipse, select FileNewXQuery File. Enter a filename and click Finish. Enter a query and save the file.
  2. Select WindowShow ViewTransformation Scenarios.
  3. In the Transformation Scenarios panel on the right-hand side, click + and select XQuery transformation in the lower part of the dropdown list.
  4. Enter a name for your transformation, e.g., “BaseX”.
  5. Specify an optional XML and XQuery URL:
    • If you would like to query a database, leave the XML URL field empty and use db:get in your XQuery URL file.
    • If you specify an XML document in the XML URL field, you can query its content using . (dot operator) in your XQuery URL file.
  6. Choose “BaseX XQJ” as Transformer from the combo box.
  7. Click OK to complete the scenario configuration.

Execute Query

After the one-time setup steps are complete, you can execute your query using the new transformation scenario. Start the transformation by clicking the red Run button (Apply associated scenarios) in the Transformation Scenarios window, while your scenario is selected. The results should be immediately displayed in the result panel.

Changelog

Version 13.0
  • Added: Instructions for accessing database resources via WebDAV were re-added.

⚡Generated with XQuery