Integrating Eclipse

From BaseX Documentation
Revision as of 10:46, 11 February 2019 by Sabine Teubner (talk | contribs)
Jump to navigation Jump to search

This tutorial is part of the Getting Started Section. It 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 it a little bit different.

Currently, there are two alternatives how to use BaseX in oXygen:

  • Resources in BaseX databases can be opened and modified.
  • XPath/XQuery 1.0 expressions can be run by the query processor of BaseX.
  • Note: BaseX itself is a highly compliant XQuery 3.1 processor. The restriction to XQuery 1.0 arises from the XQJ Interface which is used to establish the connection between oXygen and BaseX. We strongly 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 current version of the oXygen XML Editor plugin was tested for Eclipse Version 4.8. 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.
  3. In Eclipse, click on the oXygen icon in the right upper 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.
    Oxygen-eclipse-plugin.png

Access Database Resources

Preparations

  1. Download one of the BaseX distributions.
  2. Start BaseX (see Startup).
  3. Create a BaseX database, if necessary (see Databases).
  4. Start the BaseX WebDAV service.

Configuration

  1. In Eclipse, go to menu EclipsePreferences. In the Preferences dialog, chose 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 "WebDAV (S)FTP" in the Data Source dropdown box.
  5. Fill in the appropriate connection details as follows:
    • Set the WebDAV/FTP URL to http://localhost:8984/webdav.
    • Set the user name to admin.
    • Set the password to admin.
    Oxygen-eclipse-plugin-webdav-connection.png
  6. Press OK to close the dialog.
  7. In the Preferences dialog, chose the oXygen XML EditorNetwork Connection SettingsHTTP(S)/WebDAV subitem. Activate the Enable the HTTP/WebDAV protocols check box to enable WebDAV support.
  8. Click Apply and Close to close the Preferences dialog.
  9. If prompted, restart Eclipse to activate all changes.

You can then access your database file(s) via the Data Source Explorer: WindowsShow ViewData Source Explorer.

Oxygen-WebDAV-2.png

Perform Queries

One-Time Setup

Configuration

  1. In Eclipse, go to menu EclipsePreferences. In the Preferences dialog, chose 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 (downloaded in Preparations procedure) with the Add Files 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-9.0.jar
    • basex/BaseX.jar, if you want to use BaseX embedded
  5. Under "Driver class", choose the preferred driver class:
    • Embedded: net.xqj.basex.BaseXXQDataSource
    • Client/server: net.xqj.basex.local.BaseXXQDataSource
  6. Click OK.
    Oxygen-eclipse-plugin-data-source.png