Difference between revisions of "Graphical User Interface"

From BaseX Documentation
Jump to navigation Jump to search
Line 3: Line 3:
  
 
==Startup==
 
==Startup==
First of all, please launch a GUI instance of BaseX: double click on the '''BaseX GUI''' icon, or run the <code>basexgui</code> script. [[Startup#BaseX GUI|Follow this link]] for more information (or check out the additional [[Startup Options#BaseX GUI|command-line options]]).
+
First of all, please launch a GUI instance of BaseX. Depending on your operating system, double click on the '''BaseX GUI''' start icon or run the <code>basexgui</code> script. [[Startup#BaseX GUI|Follow this link]] for more information (or check out the additional [[Startup Options#BaseX GUI|command-line options]]).
  
 
== Create Database ==
 
== Create Database ==

Revision as of 10:22, 17 September 2011

The BaseX homepage gives you a visual impression of the graphical user interface (GUI) of BaseX, and the introductory video presents some of the interactive features that the BaseX GUI provides. This small tutorial demonstrates how easy it is to perform simple XPath queries.

Startup

First of all, please launch a GUI instance of BaseX. Depending on your operating system, double click on the BaseX GUI start icon or run the basexgui script. Follow this link for more information (or check out the additional command-line options).

Create Database

Select DatabaseNew and browse to the factbook.xml document. This XML file contains statistical information on the worlds' countries. It is included in the official releases of BaseX, and it can also be downloaded here.

Next, choose the OK button, and BaseX will create a database that you can visually explore.

Example Queries

Apart from the basic search facilities, BaseX offers far more sophisticated processing options to query your documents. Below are some examples you might give a try. This guide is far from being a comprehensive XQuery reference, but might point you in the right direction.

To execute the following queries, enter them in the XQuery Panel and hit the PLAY button.

XPath

XPath provides an easy facility to query your documents in a navigational manner. It is the basic tool of all node-related operations that you encounter when using XQuery. We will start with a trivial example and extend it to our needs.

Find all Countries

//country

tells BaseX to look for all country elements in the document. The query is introduced by two slashes //, which trigger the traversal of all document nodes. XPath knows several location steps that determine which nodes to consider next for evaluation.

As an example, //country is equivalent to /descendant::country.

Find the Names of all Countries

//country/name

This query returns the name children of all country elements. The result looks as follows:

<name>Albania</name>
<name>Andorra</name>
...

Find the Names of all Cities in Switzerland

The following query uses a predicate [...] to filter all country nodes which have a name child, the string value of which is "Switzerland":

//country[name = "Switzerland"]

To return all cities of the resulting element node, the query can be extended by a trailing //city path:

//country[name = "Switzerland"]//city

What's Next?

For more information on BaseX, XQuery and XPath, we invite you to...