<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/p-message-005.xml"
        name="p-message-005.xml"
        expected="pass">
   <t:info>
      <t:title>p-message-005</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-12-06</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that p:message outputs an array.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                      xmlns:err="http://www.w3.org/ns/xproc-error"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:s="http://purl.oclc.org/dsdl/schematron"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      version="3.0">
         <p:import href="https://xmlcalabash.com/ext/library/pipeline-messages.xpl"/>
         <p:output port="result"/>
         <p:message name="message" test="true">
            <p:with-option name="select"
                           select="array {           map { 'a': 1 },           map { 'b': 2 },           map { 'c': 3 },           xs:gYearMonth('2025-12') }"/>
            <p:with-input>
               <doc/>
            </p:with-input>
         </p:message>
         <cx:pipeline-messages p:depends="message" level="info" message-attribute="false"/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
         <s:ns prefix="cx" uri="http://xmlcalabash.com/ns/extensions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="cx:messages">The document root is not correct.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/cx:messages">
               <s:assert test="cx:message[@level='INFO'                     and contains(., '&#xA; ')                     and contains(., '&#34;a&#34;:')                     and contains(., '&#34;2025-12&#34;')]">No message output.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="p-message-005.xml">
      <cx:messages xmlns:cx="http://xmlcalabash.com/ns/extensions">
         <cx:message date="2026-07-18T16:02:10+00:00" level="INFO">[
  { "a":1 },
  { "b":2 },
  { "c":3 },
  "2025-12"
]</cx:message>
      </cx:messages>
   </t:result>
</t:test>
