Name

cx:elemental — Evaluate XQuery expressions with Elemental.

Synopsis

This step sends an XQuery expression to an external Elemental database.

Input portPrimarySequenceContent typesDefault binding
source✔ ✔ any p:empty
query  text xml 
Output portPrimarySequenceContent typesDefault binding
result✔ ✔ any 
Option nameTypeDefault value
database-urixs:anyURI?()
parametersmap(xs:QName,item()*)?()
passwordxs:string?()
query-parametersmap(xs:QName, item()*)?()
query-propertiesmap(xs:QName, item()*)?()
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/elemental.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:empty/>
   |   </p:input>
   |   <p:input port="query" content-types="text xml"/>
   |   <p:output port="result" sequence="true" content-types="any"/>
10 |   <p:option name="parameters" as="map(xs:QName,item()*)?"/>
   |   <p:option name="version" as="xs:string?"/>
   |   <p:option name="database-uri" as="xs:anyURI?"/>
   |   <p:option name="username" as="xs:string?"/>
   |   <p:option name="password" as="xs:string?"/>
15 |   <p:option name="query-parameters" as="map(xs:QName, item()*)?"/>
   |   <p:option name="query-properties" as="map(xs:QName, item()*)?"/>
   |</p:declare-step>

In order to use the Elemental with XML Calabash, you must also download the XML Calabash extension step for Elemental, elemental-3.0.15.zip and add its resources to your classpath. If you are using Maven, include the Elemental step in your dependencies: com.xmlcalabash:elemental:3.0.15.

Description

This step is modeled on the p:xquery step, but specifically uses the Elemental implementation. If values are given for database-uri, username, and password, they override any values given in the configuration file. Any query parameters or properties defined in the configuration file are merged with the query-parameters and query-properties option maps. The cx:elemental 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://elemental.xyz/.

When Elemental is used as the query processor (with either the cx:elemental step or when it is used as the default XQuery processor), it always queries an Elemental database. You cannot pass documents to the step.

Queries that bind external variables to atomic values and return XML documents seem to work fine. Passing non-atomic values, returning non-XML results, or returning a sequence of results often don’t work. It’s not clear if this is due to bugs in the REST API or misunderstandings about how the API works. Suggestions for improvements most welcome.

Options

The cx:elemental step has several additional options beyond the standard p:xquery options. They are currently the same as the options on the cx:exist-db step.

Note

The documentation for Elemental is currently under construction. This section will get updated when the documentation is ready.

Configuration

The cc:xquery-processor element in the configuration file provides default values for some Elemental properties.

The following attributes are recognized:

Attribute nameAttribute value
namehttps://elemental.xyz/
database-uriThe REST API endpoint
usernameThe username
passwordThe password
existdb:*Query parameters
ser:*Query properties

Where existdb is bound to http://exist.sourceforge.net/NS/exist and ser is bound to http://exist-db.org/xquery/types/serialized.

For example:

1 |<cc:xquery-processor xmlns:exist="http://exist.sourceforge.net/NS/exist"
  |                     xmlns:ser="http://exist-db.org/xquery/types/serialized"
  |                     name="https://elemental.xyz/"
  |                     database-uri="http://localhost:8080/exist/rest/db/"
5 |                     username="admin" password="secret"
  |                     exist:max="10" ser:omit-xml-declaration="yes"/>