Changes

Jump to navigation Jump to search
1,369 bytes added ,  22:39, 9 October 2016
no edit summary
This page is part of the [[Getting Started]] Section.
The BaseX homepage gives you a [http://basex.org/products/gui visual impression] of the graphical user interface (GUI) of BaseX,and the an [http://www.youtube.com/watch?v=xILHKGPGaJ4&hd=1 introductory video] is available, which presents some of the its 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 <code>basexgui</code> script. Beside that, some more [[Startup#BaseX GUI|startup options]] are available.
== Create Database ==
Select ''Database'' → ''New'' and browse to an XML document of your choice. As an example, you can start with the {{Code|factbook.xml}} document, which contains statistical information on the worlds' countries. It is included in our official releases and can also be [http://files.basex.org/xml/factbook.xml downloaded] (1.3 MB). If you type nothing in the input field, an empty database will be created. Next, choose the ''OK'' button, and BaseX will create a database that you can visually explore and query.
NextIf no XML document is available, choose the ''OK'' button[[#Text Editor|Text Editor]] can also be used to create an initial XML document. After saving the entered XML document to harddisk, and BaseX will create a it can be supplied as database that you can visually exploreinput in the above dialog.
==Realtime Options=Input Bar=
Via On top of the main window, you can find an input bar. The attached dropdown menu provides three modes: ''Options'Find''' menu, you can change the way how queries are executed '''XQuery''' and visualized'''Command''':
* '''Realtime Execution''': If realtime execution is enabled, your searches and queries will be executed with each key click and the results will be instantly shown.* '''Realtime Filtering''': If enabled, all visualizations will be limited to the actual results in realtime. If this feature is disabled, the query results are highlighted in the visualizations and can be ecplicitly filtered with the 'Filter' button.[[CategoryImage:GUIInputBar.png|Input Bar]]
== Querying ==The upcoming example queries can all be used with an instance of the <code>factbook</code> database:
=== Keyword Search =Find==
The Keyword Search can be executed in In the '''SearchFind''' mode in, the combo box of the main window. This options allows for a simple,keyword-based search input bar can be used to find single elements and texts in the currently opened database.The following syntax is supported:
The following syntax is supported:
{| class="wikitable"
!Query
!Description
|-
|<code>worldcity</code>|Find tags elements named {{Code|city}}, and texts containing this token.|-|<code>=India</code>|Find texts matching the exact string {{Code|India}}.|-|<code>~Cing</code>|Find texts equal or similar to the token {{Code|Cingdom}}.|-|<code>id</code>|Find attributes named {{Code|id}} and attribute values containing this token.|-|<code>@=f0_119</code>|Find attribute values matching the exact string {{Code|worldf0_119}}.
|-
|<code>=world"European Chinese"</code>|Find exact matching text nodestexts containing the phrase {{Code|"European Chinese"}}.
|-
|<code>~world//city</code>|Find text nodes similar to Leading slash: Interpret the input as XPath expression (see below).|} ==XQuery== In the '''XQuery''' mode, XPath and XQuery expressions can be entered in the input bar. To evaluate the following example queries: enter them in the input bar, and press ENTER or click on the START button: {{Code|world}}class="wikitable"!Query!Description
|-
|<code>@world//country</code>|Find attributes and attribute valuesReturn all <code>country</code> elements.
|-
|<code>@//country[name =world"Switzerland"]</code>|Find exact attribute valuesReturn the <code>country</code> element of "Switzerland".
|-
|<code>"united world"for $city in //city<br/>where $city/population > 1000000<br/>order by $city ascending<br/>return $city/name</code>|Find tags Return the names of all cities with a population larger than one million and texts containing order the results by the name of the phrase {{Code|"united world"}}city.
|}
=== XPath/XQuery =Command==
Apart from In the basic search facilities'''Command''' mode, [[Commands|BaseX offers far more sophisticated processing options to query your documentsCommands]] can be entered and executed. Below are some examples you might give a Just try. This guide is far from being a comprehensive XQuery reference, but might point you in the right direction.following examples:
To execute the following queries, enter them in the XQuery Panel and press ENTER or click on the START button* <code>INFO</code>: Returns system information.* <code>CREATE DB TEST</code>: Creates an empty database named "TEST".* <code>LIST</code>: Lists all databases.
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.=Text Editor=
''' ExampleThe powerful text editor can be used to write and edit [[XQuery]] code (simple queries, modules), XML documents, [[Commands#Basics|Command Scripts]], and any other textual files: Find Countries '''
<pre class="brush:xquery">//country</pre>* XQuery and command scripts can be '''executed''' by clicking on the green triangle. * XQuery, XML and JavaScript will be '''syntax highlighted'''.* XQuery and XML will automatically '''parsed''' with each key click, and '''errors''' will be highlighted.
tells BaseX Numerous [[Shortcuts|keyboard shortcuts]] are available 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. The queries {{Code|//country}} andd {{Code|/descendant::country}} will return the same resultsspeed up editing and debugging.
''' Example: Find Cities in Switzerland '''==Project View==
The following query uses Project View is attached to the editor panel. It displays all files of the current project directory in a '''predicate''' tree structure. Files can be renamed and deleted by right-clicks on the files. The project directory can be changed by clicking on the button with the three dots <code>[...]</code> to filter all <code>country</code> nodes which have a <code>name</code> child, in the string value upper left corner of which is "Switzerland":the project view panel.
<pre class="brush:xquery">//country[name = "Switzerland"]</pre>Erroneous XQuery modules, and all queries importing these modules, will be highlighted. Highlighting can be disabled in the GUI preferences dialog.
To return all cities of the resulting element node, the query can be extended by a trailing <code>//city</code> path:=Realtime Options=
<pre class="brushVia the ''Options'' menu, you can change how queries are executed and visualized:xquery">//country[name = "Switzerland"]//city</pre> * '''Realtime Execution''': If realtime execution is enabled, your searches and queries will be executed with each key click and the results will be instantly shown.* '''Realtime Filtering''': If enabled, all visualizations will be limited to the actual results in realtime. If this feature is disabled, the query results are highlighted in the visualizations and can be explicitly filtered with the 'Filter' button.
== Visualizations ==
The BaseX GUI offers various visualizations,
which help you to explore your XML data instances from different perspectives:
<table cellpadding="0" cellspacing="010"><tr><td valign="top" width="49%">[[Image:TextViewResult.jpgpng|thumb|Text View]]
'''TextResult'''
:Displays query results and other textual output. Query results can be saved in a file.
</td><td valign="top" width="2%">&nbsp;</td><td valign="top" width="49%">[[Image:MapViewMap.jpgpng|thumb|Map View]]
'''Map'''
:This visualization represents Displays all data in a [http://en.wikipedia.org/wiki/Treemap TreeMap]. All nodes of the XML document are represented as rectangles, filling the complete area. You can choose different layout algorithms in the Menu ''Options'' → ''Map Layout''.
</td></tr><tr><td valign="top">
[[Image:TreeViewTree.jpgpng|thumb|Tree View]]
'''Tree'''
:This visualization displays Displays all XML nodes in a top down tree with edges and nodes. You can change some settings of the Tree in the Menu ''Options'' → ''Tree Options''.</td><td valign="top" width="2%">&nbsp;</td><td valign="top" width="49%">[[Image:FolderViewFolder.jpgpng|thumb|Folder View]]
'''Folder'''
:This visualization displays Displays all nodes in an Explorer-like folder view. Nodes can be expanded or closed by clicking on the arrows.
</td></tr><tr><td valign="top">
[[Image:Scatterplot.jpgpng|thumb|Scatterplot View]]
'''Plot'''
:This visualization displays Displays all nodes in a scatterplot, which is particularly helpful if you want to explore analyze your data. Three drop down menus allow custom axis assignments.</td><td valign="top" width="2%">&nbsp;</td><td valign="top" width="49%">[[Image:TableViewTable.jpgpng|thumb|The Table View]]
'''Table'''
:This visualization comes Comes in handy if your data is highly regular. It displays all nodes in a table with rows and columns. Different assignments can be chosen by clicking on the arrow in the right upper corner.
</td></tr><tr><td valign="top">
[[Image:ExplorerViewExplorer.jpgpng|thumb|Explorer View]]
'''Explorer'''
:With this visualization you can Can be used to explore the contents of your database via drop-down menus, search fields and double sliders.</td><td valign="top" width="2%">&nbsp;</td><td valign="top" width="49%">
[[Image:InfoView.png|thumb|Info View]]
'''Info'''
:This view is helpful Helpful for analyzing the query plans of your XQuery expressions. It also displays information on the compilation and evaluation of queries.
</td></tr></table>
=Look and Feels= What <table> <tr> <td>By default, the Look and Feel of your operating system will be used in the GUI.In the 's Next? 'Preferences'' dialog, you can choose among some more window themes. The [http://www.jtattoo.net/ScreenShots.html JTattoo library] offers some morelook and feels. If you download and copy the JTattoo jar file into the {{Code|lib}}directory provided by the ZIP and EXE distribution of BaseX,13 additional looks and feels will get available. </td> <td>[[Image:defaultlaf.png|thumb|Default Look & Feel]]</td> <td>[[Image:hifilaf.png|thumb|HiFi Look & Feel]]</td> </tr></table> =Changelog;Version 8.4 * Added: highlighting of erroneous XQuery modules in the project view.
Various tutorials on XPath are available in the internet. We invite you to e.g. have a look at the [http://www.w3schools.com/xquery/ XQuery Tutorial at W3Schools];Version 8.0
[[Category* Updated:Beginner]][[Category:GUI]][[Category:XQuery]]support for dark look and feels; support for JTatto library
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu