Difference between revisions of "Integrating Eclipse"

From BaseX Documentation
Jump to navigation Jump to search
m (Text replacement - "[http://basex.org/" to "[https://basex.org/")
 
(6 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
This tutorial is part of the [[Getting Started]] Section.
 
This tutorial is part of the [[Getting Started]] Section.
 
It describes how to access BaseX from [https://www.eclipse.org Eclipse] via the [https://www.oxygenxml.com/doc/versions/20.1/ug-editorEclipse/topics/introduction.html oXygen XML Editor plugin].
 
It describes how to access BaseX from [https://www.eclipse.org Eclipse] via the [https://www.oxygenxml.com/doc/versions/20.1/ug-editorEclipse/topics/introduction.html 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.
+
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:
 
Currently, there are two alternatives how to use BaseX in oXygen:
Line 13: Line 13:
 
# 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.
 
# 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.
 
# Follow the instructions in the [https://www.oxygenxml.com/doc/versions/20.1/ug-editorEclipse/topics/install-eclipse.html oXygen Manual] to install the plugin.
 
# Follow the instructions in the [https://www.oxygenxml.com/doc/versions/20.1/ug-editorEclipse/topics/install-eclipse.html oXygen Manual] to install the plugin.
# 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''.
+
# 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''.
 
#: [[File:oxygen-eclipse-plugin.png]]
 
#: [[File:oxygen-eclipse-plugin.png]]
  
Line 20: Line 20:
 
===Preparations===
 
===Preparations===
  
# Download one of the [http://basex.org/download BaseX distributions].
+
# Download one of the [https://basex.org/download BaseX distributions].
 
# Start BaseX (see [[Startup]]).
 
# Start BaseX (see [[Startup]]).
 
# Create a BaseX database, if necessary (see [[Databases]]).
 
# Create a BaseX database, if necessary (see [[Databases]]).
Line 26: Line 26:
  
 
===Configuration===
 
===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.
  
 
# In Eclipse, go to menu ''Eclipse'' → ''Preferences''. In the ''Preferences'' dialog, chose the ''oXygen XML Editor'' item, and then the ''Data Sources'' subitem.
 
# In Eclipse, go to menu ''Eclipse'' → ''Preferences''. In the ''Preferences'' dialog, chose the ''oXygen XML Editor'' item, and then the ''Data Sources'' subitem.
Line 37: Line 39:
 
#: [[File:oxygen-eclipse-plugin-webdav-connection.png]]
 
#: [[File:oxygen-eclipse-plugin-webdav-connection.png]]
 
# Press ''OK'' to close the dialog.
 
# Press ''OK'' to close the dialog.
# In the ''Preferences'' dialog, chose the ''oXygen XML Editor'' → ''Network Connection Settings'' → ''HTTP(S)/WebDAV'' subitem. Activate the ''Enable the HTTP/WebDAV protocols'' check box to enable WebDAV support.
+
<!--# In the ''Preferences'' dialog, chose the ''oXygen XML Editor'' → ''Network Connection Settings'' → ''HTTP(S)/WebDAV'' subitem. Activate the ''Enable the HTTP/WebDAV protocols'' check box to enable WebDAV support.-->
 
# Click ''Apply and Close'' to close the ''Preferences'' dialog.
 
# Click ''Apply and Close'' to close the ''Preferences'' dialog.
 
# If prompted, restart Eclipse to activate all changes.
 
# If prompted, restart Eclipse to activate all changes.
Line 48: Line 50:
  
 
==One-Time Setup==
 
==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===
 
===Configuration===
Line 64: Line 68:
 
# Click ''OK''.
 
# Click ''OK''.
 
#: [[File:oxygen-eclipse-plugin-data-source.png]]
 
#: [[File:oxygen-eclipse-plugin-data-source.png]]
 +
 +
===Configure Connection===
 +
 +
# In the Connections section (in the lower half of the Data Source dialog), click ''New'' ({{Code|+}}).
 +
# Enter "BaseX XQJ" as name and select "BaseX" as data source.
 +
# If you use the default driver, enter the following values in the Connection Details section:
 +
#* port: {{Code|1984}}
 +
#* serverName: {{Code|localhost}}
 +
#* user: {{Code|admin}}
 +
#* password: {{Code|admin}}
 +
#: [[File:oxygen-eclipse-plugin-xqj-connection.png]]
 +
# Click ''OK'' to complete the connection configuration.
 +
# Click ''Apply and Close'' to close the ''Preferences'' dialog.
 +
# If prompted, restart Eclipse to activate all changes.
 +
 +
===Configure New Transformation Scenario===
 +
 +
# In Eclipse, choose ''File'' → ''New'' → ''XQuery File''. Enter a filename and click ''Finish''. Enter a query and save the file.
 +
# Select ''Window'' → ''Show View'' → ''Transformation Scenarios''.
 +
# In the ''Transformation Scenarios'' panel on the right-hand side, click {{Code|+}} and select ''XQuery transformation'' in the lower part of the dropdown list.
 +
# Enter a name for your transformation, e.g. "BaseX".
 +
# Specify an optional XML and XQuery URL.
 +
#* If you would like to query the BaseX database you connected to via WebDAV, leave the ''XML URL'' field empty. To access your database, you can use the {{Code|db:open}} function from the BaseX [[Database_Module|Database Module]] in your ''XQuery URL'' file.
 +
#* If you specify an XML document in the ''XML URL'' field, you can query its content using {{Code|.}} (dot operator) in your ''XQuery URL'' file.
 +
# Choose "BaseX XQJ" as Transformer from the combo box.
 +
# Click ''OK'' to complete the scenario configuration.
 +
 +
[[File:oxygen-eclipse-plugin-transformation.png]]
 +
 +
==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.

Latest revision as of 12:51, 2 July 2020

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[edit]

  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 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.
    Oxygen-eclipse-plugin.png

Access Database Resources[edit]

Preparations[edit]

  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[edit]

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 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. Click Apply and Close to close the Preferences dialog.
  8. 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[edit]

One-Time Setup[edit]

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[edit]

  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

Configure Connection[edit]

  1. In the Connections section (in the lower half of the Data Source 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: admin
    Oxygen-eclipse-plugin-xqj-connection.png
  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[edit]

  1. In Eclipse, choose 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 the BaseX database you connected to via WebDAV, leave the XML URL field empty. To access your database, you can use the db:open function from the BaseX Database Module 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.

Oxygen-eclipse-plugin-transformation.png

Execute Query[edit]

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.