Name
cx:basex — Evaluate XQuery expressions.
Synopsis
This step applies an XQuery expression to the sequence of documents provided on the source port an external BaseX database.
Input port | Primary | Sequence | Content types |
---|---|---|---|
source | ✔ | ✔ | any |
query | text xml |
Output port | Primary | Sequence | Content types |
---|---|---|---|
result | ✔ | ✔ | any |
Option name | Type | Default value |
---|---|---|
host | xs:string? | () |
parameters | map(xs:QName,item()*)? | () |
password | xs:string? | () |
port | xs:integer? | () |
username | xs:string? | () |
version | xs:string? | () |
<p:import href="https://xmlcalabash.com/ext/library/basex.xpl"/>
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
| <p:input port="source"
| content-types="any"
| sequence="true"
5 | primary="true"/>
| <p:input port="query" content-types="text xml"/>
| <p:output port="result" sequence="true" content-types="any"/>
| <p:option name="parameters" as="map(xs:QName,item()*)?"/>
| <p:option name="version" as="xs:string?"/>
10 | <p:option name="host" as="xs:string?"/>
| <p:option name="port" as="xs:integer?"/>
| <p:option name="username" as="xs:string?"/>
| <p:option name="password" as="xs:string?"/>
|</p:declare-step>
In order to use the BaseX with XML Calabash, you must also download the XML Calabash extension
step for BaseX, basex-3.0.15.zip
and add its resources to your classpath. If you
are using Maven, include the BaseX step in your dependencies:
com.xmlcalabash:basex:3.0.15
. This step also requires the BaseX API
libraries.
Description
This step is modeled on the p:xquery
step, but specifically uses
the BaseX implementation. If values
are given for host
, port
, username
,
and password
, they override any values given in the
configuration
file.
The cx:basex
step can also be nominated as the default processor for p:xquery
by setting the
default
XQuery processor. It can also be specified for a single instance of p:xquery
by setting the cx:processor
attribute to
https://basex.org/
.
The following parameters (in the standard parameters
option)
also apply. (When BaseX is used as the default p:xquery
processor, this is
the only way to set them.)
Parameter name | Parameter value |
---|---|
cx:host | The host name |
cx:port | The port number |
cx:username | The username |
cx:password | The password |
Where the cx
prefix is bound to the XML Calabash extension namespace,
http://xmlcalabash.com/ns/extensions
.
The BaseX implementation of XQuery (whether it’s accessed with the cx:basex
step or through the p:xquery
step) operates in one of two modes:
local or remote.
BaseX local mode
In local mode, you must not specify host, port, username or password.
The documents that appear on the source port are used to construct an in-memory BaseX database and that database is queried. The results of that query form the results of the step.
In this configuration, the default context is always the entire default collection.
This is a slightly different semantic than the one described by the p:xquery
step.
It arises as a consequence of the way the BaseX API works.
BaseX remote mode
In remote mode, you must specify host, port, username and password. There must be no documents on the source port.
The host, port, etc. are used to connect to a BaseX database. If that connection succeeds, the query is sent to the database and results returned form the results of the step.
Configuration
The
cc:xquery-processor
element in the
configuration file
provides default values for some BaseX properties.
The following attributes are recognized:
Attribute name | Attribute value |
---|---|
name | https://basex.org/ |
host | The host name |
port | The port number |
username | The username |
password | The password |
For example:
|<cc:xquery-processor name="https://basex.org/"
| username="admin" password="secret"
| port="1984" host="localhost"/>