Changes

Jump to navigation Jump to search
No change in size ,  07:22, 22 September 2011
no edit summary
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 ====
 
<code> //country</code>
 
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.
 
As an example, <code>//country</code> is equivalent to <code>/descendant::country</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>
== Visualizations ==
:This visualization gives details on the execution of database commands and XQuery expressions.
</td></tr></table>
 
== 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 ====
 
<code> //country</code>
 
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.
 
As an example, <code>//country</code> is equivalent to <code>/descendant::country</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? ==
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu