Name
cx:pipeline-messages — Accesses pipeline message output.
Synopsis
Output port | Primary | Sequence | Content types |
---|---|---|---|
result | ✔ |
Option name | Type | Default value |
---|---|---|
clear | xs:boolean | false() |
level | xs:string? | () |
Declaration
1 |<p:declare-step xmlns:p="http://www.w3.org/ns/xproc">
| <p:option name="level" as="xs:string?" select="()"/>
| <p:option name="clear" as="xs:boolean" select="false()"/>
| <p:output port="result"/>
5 |</p:declare-step>
Description
XML Calabash maintains a buffer of messages generated by the pipeline.
This includes both the messages generated by the pipeline itself, as well as the
messages generated by steps. For example, p:xsl-message
output
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 as 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. |
/> |
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 |<?xml version="1.0" encoding="UTF-8"?>
|<cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
| <cx:message code="Q{http://www.w3.org/2005/xqt-errors}XTMM9000"
| step-name="xslt"
5 | system-identifier="file:/home/runner/work/xmlcalabash3/xmlcalabash3/documentation/src/examples/xpl/messages.xpl"
| line-number="19"
| column-number="63"
| level="INFO"
| message="Ran an identity transform."
10 | date="2025-01-08T09:27:09.095962467"/>
|</cx:messages>