<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/seq-of-items-004.xml"
        name="seq-of-items-004.xml"
        expected="pass">
   <t:info>
      <t:title>seq-of-items-004</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-08-04</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Changed expected type of variable to 'array(xs:double)*'.</p>
            </t:description>
         </t:revision>
         <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 arrays.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:array="http://www.w3.org/2005/xpath-functions/array"
                      xmlns:p="http://www.w3.org/ns/xproc"
                      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">[1.1,2.2]</p:inline>
            <p:inline content-type="application/json" expand-text="false">[3.3,4.4]</p:inline>
         </p:input>
         <p:variable name="v"
                     as="array(xs:double)*"
                     collection="true"
                     select="collection()"/>
         <p:identity>
            <p:with-input select="array:join($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 xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://purl.oclc.org/dsdl/schematron"
                queryBinding="xslt2">
         <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="fn:array">The root element is incorrect.</s:assert>
            </s:rule>
         </s:pattern>
         <s:pattern>
            <s:rule context="/fn:array">
               <s:assert test="count(fn:number) = 4">Wrong number of numbers</s:assert>
               <s:assert test="fn:number[1] = 1.1">The first item is incorrect</s:assert>
               <s:assert test="fn:number[2] = 2.2">The second item is incorrect</s:assert>
               <s:assert test="fn:number[3] = 3.3">The third item is incorrect</s:assert>
               <s:assert test="fn:number[4] = 4.4">The fourth item is incorrect</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="seq-of-items-004.xml">
      <array xmlns="http://www.w3.org/2005/xpath-functions">
         <number>1.1</number>
         <number>2.2</number>
         <number>3.3</number>
         <number>4.4</number>
      </array>
   </t:result>
</t:test>
