Name
cx:pipeline-messages — Accesses pipeline message output.
Synopsis
XML Calabash maintains a buffer of messages generated by the pipeline. This step gives the pipeline access to those messages.
| Output port | Primary | Sequence | Content types |
|---|---|---|---|
| result | ✔ |
| Option name | Type | Default value |
|---|---|---|
| clear | xs:boolean | false() |
| level | xs:string? | () |
| message-attribute | xs:boolean | true() |
<p:import href="https://exproc.org/library/pipeline-messages.xpl"/>Declaration
1 |<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
| xmlns:p="http://www.w3.org/ns/xproc"
| type="cx:pipeline-messages">
| <p:option name="level" as="xs:string?" select="()"/>
5 | <p:option name="clear" as="xs:boolean" select="false()"/>
| <p:option name="message-attribute" as="xs:boolean" select="true()"/>
| <p:output port="result"/>
|</p:declare-step>Description
The XML Calabash message buffer includes both the messages generated by the
pipeline itself, as well as the messages generated by steps. For example,
xsl:message output that occurs when running the p:xslt step
appears in the buffer.
A pipeline can access the messages with the
cx:pipeline-messages step. This step returns all of the messages in
the buffer that have a level greater than or equal to the level specified
in the level option.
The messages are returned in a
cx:messages document. Each message appears in a
cx:message element.
| <cx:message | |
| level = TRACE|DEBUG|INFO|WARN|ERROR | The logging level |
| message? = string | The message text |
| date = dateTime | The message timestamp (local time) |
| {any-name} = string | Any additional attributes are allowed |
| > | |
| string | |
| </cx:message> |
If the message-attribute option is true, the message text will
be in the message attribute on the cx:message.
If it’s false, the message attribute will be absent and the message
text will be the (only) child of the cx:message element.
Attribute value normalization applies to the value of the
message attribute. If spaces and line breaks are
significant, set message-attribute option to false.
By default, XML Calabash keeps a buffer of the last 32 messages.
If the clear option is true, the message
buffer will be discarded after returning the messages.
The cx:pipeline-messages step has no inputs. It will almost
certainly be necessary to use
depends
to control when the step runs. (A step with no inputs and no dependencies is likely
to run very early, perhaps before any messages have even been generated.)
Examples
Here’s a short pipeline that applies an identity transform using
p:xslt.
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
| xmlns:cx="http://xmlcalabash.com/ns/extensions"
| version="3.0">
| <p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
5 |
| <p:input port="source"/>
| <p:output port="result"
| serialization="map { 'method': 'xml', 'indent': 'yes' }"/>
|
10 | <p:xslt name="xslt">
| <p:with-input port="stylesheet">
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
| xmlns:xs="http://www.w3.org/2001/XMLSchema"
| exclude-result-prefixes="xs"
15 | version="3.0">
| <xsl:mode on-no-match="shallow-copy"/>
| <xsl:template match="/" name="xsl:initial-template">
|
| <xsl:message select="'Ran an identity transform.'"/>
20 |
| <xsl:apply-templates/>
| </xsl:template>
| </xsl:stylesheet>
| </p:with-input>
25 | </p:xslt>
|
| <cx:pipeline-messages p:depends="xslt" level="info"/>
|</p:declare-step>Observe how the xsl:message appears in the
pipeline messages:
1 |<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
| <cx:message code="Q{http://www.w3.org/2005/xqt-errors}XTMM9000"
| step-name="xslt"
| date="2025-12-06T18:26:06+00:00"
5 | level="INFO"
| message="Ran an identity transform."/>
|</cx:messages>