Difference between revisions of "Graphical User Interface"

From BaseX Documentation
Jump to navigation Jump to search
(moved getting started guid in from homepage.)
Line 1: Line 1:
==Startup==
+
== Download ==
See the [[Startup Overview]].
 
  
==First Operations==
+
* First of all, download the latest version of [http://cms.basex.org/?id=44 BaseX].
To get to know BaseX, we advise to run some of the following operations to see how it works and
+
* Next, download an <span class="caps">XML</span> document: [http://files.basex.org/xml/factbook.xml factbook.xml] (1.2 MB) contains statistical information on the worlds� countries. This file is also included in the Windows and ZIP distribution of BaseX.
get your first indentations.  
 
  
===Create a database/collection===
 
Go to Database/New menu you can choose a folder of xml files or a single xml file
 
to either create a single xml file database or a collection with a bunch of xml files.
 
You will find some additional tabs for parser, index and full-text options:
 
  
;Parsing
+
== Create Database ==
:Here you can change settings for the parser and choose a file for your xml catalog.
 
;Indexes
 
:Here you can choose what indexes to be created with the database: text index, attribute index and path summary are available
 
: as indexes.
 
;Full-Text
 
:Here you can activate the full-text index. Furthermore some more options can be set, like language, wildcards and a stopword list.
 
  
===Add/Delete documents===
+
Select ''Database'' → ''New'' and browse to the factbook.xml document.
If you have opened a database you can add (Database/Add documents) or delete (Database/Delete documents) on an easy way.
 
Just go to the designated menu and follow the further steps.
 
  
;Add documents
+
Next, choose the OK button, and BaseX will create a database that you can visually explore.<br /> The [http://www.youtube.com/watch?v=xILHKGPGaJ4&hd=1 introductory video] gives you a glimpse of some features that the BaseX GUI provides.
: Choose a file or directory to add to your database. As <code>path</code> you can enter a target path in your database, where
 
: the new documents have to be added.
 
  
;Delete documents
 
:Enter the path of the documents which you like to delete, the info message will show you how many documents are effected.
 
  
===Manage databases===
+
== Example Queries ==
In the Database/Manage menu you can backup, restore, rename and drop a database.
 
  
;Backup
+
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.
:The backup-file is stored in the database directory.
 
:The file is named <code>db_name-timestamp.zip</code>.
 
;Restore
 
:To restore the database the file with the newest timestamp is taken.
 
  
===Execute a query===
+
To execute the following queries, enter them in the XQuery Panel and hit the PLAY button.
For executing a query there are two ways:
 
  
;Search mode in the combo box of the main window
+
=== XPath ===
:Here you can enter your query with the help of the query suggest feature, which will provide you with suggestions for path steps.
 
  
;Query View
+
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.
:Here you can enter your query with the help of an advanced query editor with syntax highlighting and detailed error feedback.
 
  
If you are not familiar with XQuery, you can execute an [[Easy Search]].
+
==== Find all Countries ====
  
==See also ==
+
<code> //country</code>
[[Standalone Tutorial]], [[Server Tutorial]], [[Getting Started]], [[Advanced Usage]]
+
 
[[Category:Beginner]]
+
tells BaseX to look for all <code>country</code> elements in the document. The query is introduced by two slashes <code>//</code>, which trigger the traversal of all document nodes. XPath knows several '''location steps''' that determine which nodes to consider next for evaluation.
[[Category:GUI]]
+
 
 +
As an example, <code>//country</code> is equivalent to <code>/descendant::country</code>.
 +
 
 +
==== Find the Names of all Countries ====
 +
 
 +
<code> //country/name</code>
 +
 
 +
This query returns the <code>name</code> children of all <code>country</code> elements. The result looks as follows:
 +
 
 +
<code> <name>Albania</name><br /> <name>Andorra</name><br /> ...</code>
 +
 
 +
==== Find the Names of all Cities in Switzerland ====
 +
 
 +
The following query uses a '''predicate''' <code>[...]</code> to filter all <code>country</code> nodes which have a <code>name</code> child, the string value of which is "Switzerland":
 +
 
 +
<code> //country[name = "Switzerland"]</code>
 +
 
 +
To return all cities of the resulting element node, the query can be extended by a trailing <code>//city</code> path:
 +
 
 +
<code> //country[name = "Switzerland"]//city</code>
 +
 
 +
 
 +
== What's Next? ==
 +
 
 +
For more information on BaseX, XQuery and XPath, we invite you to...
 +
 
 +
* check out our [[Documentation]], and
 +
* have a look at the [http://www.w3schools.com/xquery/ XQuery Tutorial at W3Schools].

Revision as of 12:08, 17 January 2011

Download

  • First of all, download the latest version of BaseX.
  • Next, download an XML document: factbook.xml (1.2 MB) contains statistical information on the worlds� countries. This file is also included in the Windows and ZIP distribution of BaseX.


Create Database

Select Database → New and browse to the factbook.xml document.

Next, choose the OK button, and BaseX will create a database that you can visually explore.
The introductory video gives you a glimpse of some features that the BaseX GUI provides.


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...