<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <t:info>
      <t:title>seq-of-items-003</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-08-03</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Added test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Test that type checking works for a sequence of maps.</p>
   </t:description>
   <t:pipeline>

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:map="http://www.w3.org/2005/xpath-functions/map"
                xmlns:xs="http://www.w3.org/2001/XMLSchema"
                name="main" version="3.0">
  <p:output port="result" primary="true" sequence="false"/>
  <p:input port="source" primary="true" sequence="true" content-types="application/json">
    <p:inline content-type="application/json" expand-text="false">{"a":1}</p:inline>
    <p:inline content-type="application/json" expand-text="false">{"b":2}</p:inline>
  </p:input>

  <p:variable name="v" as="map(*)*" collection="true" select="collection()"/>

  <p:identity>
    <p:with-input select="map:merge($v)">
      <p:inline><doc/></p:inline>
    </p:with-input>
  </p:identity>

  <p:cast-content-type content-type="application/xml"/>
</p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema queryBinding="xslt2"
                xmlns:s="http://purl.oclc.org/dsdl/schematron"
                xmlns="http://www.w3.org/1999/xhtml">
        <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
           <s:rule context="/">
             <s:assert test="fn:map">The root element is incorrect.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
           <s:rule context="/fn:map">
             <s:assert test="count(fn:number) = 2">Wrong number of numbers</s:assert>
             <s:assert test="count(fn:*) = 2">Wrong number of elements</s:assert>
             <s:assert test="fn:number[@key='a'] = 1">Map a is incorrect</s:assert>
             <s:assert test="fn:number[@key='b'] = 2">Map b is incorrect</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>
