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 portPrimarySequenceContent types
source✔ ✔ any 
query  text xml 
Output portPrimarySequenceContent types
result✔ ✔ any 
Option nameTypeDefault value
hostxs:string?()
parametersmap(xs:QName,item()*)?()
passwordxs:string?()
portxs:integer?()
usernamexs:string?()
versionxs:string?()
This is an extension step; to use it, your pipeline must include its declaration. For example, by including the extension library with an import at the top of your pipeline:
<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 nameParameter value
cx:hostThe host name
cx:portThe port number
cx:usernameThe username
cx:passwordThe 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 nameAttribute value
namehttps://basex.org/
hostThe host name
portThe port number
usernameThe username
passwordThe password

For example:

  |<cc:xquery-processor name="https://basex.org/"
  |                     username="admin" password="secret"
  |                     port="1984" host="localhost"/>