<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
        features="xquery_3_1"
        xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <t:info>
      <t:title>p:xquery 036 (AB)</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2026-10-29</t:date>
            <t:author>
               <t:name>Achim Berndzen</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Initial commit</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests types of variables are set correctly (Part 1)</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc" 
         xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
         <p:output port="result"/>
         
         <p:xquery version="3.1"
            parameters="map{'variable' : (xs:untypedAtomic('untyped'),
               xs:dateTime('2006-05-03T13:20:00'),
               xs:date('2006-05-03'),
               xs:time('13:30:00'),
               xs:yearMonthDuration('P3Y5M'),
               xs:dayTimeDuration('P2DT3H'),
               xs:float('3.0'),
               xs:double('42.42'),
               xs:decimal('42'),
               xs:gYearMonth('2026-06'),
               xs:gYear('2025'),
               xs:gMonthDay('--05-03'),
               xs:gDay('---04'),
               xs:gMonth('--06 '),
               xs:boolean('false'),
               xs:base64Binary('0CD7'),
               xs:hexBinary('0CD7'),
               xs:anyURI('http://test'),
               QName('http://test', 'name'))}" >
            <p:with-input port="source">
               <p:empty />
            </p:with-input>
            <p:with-input port="query" xml:base="http://xquery-uri">
               <p:inline content-type="text/plain">
                  declare namespace xs ="http://www.w3.org/2001/XMLSchema";
                  declare variable $variable external;
                  
                  &lt;tests>
                     &lt;untyped-test>{{$variable[1] instance of xs:untypedAtomic}}&lt;/untyped-test>
                     &lt;dateTime-test>{{$variable[2] instance of xs:dateTime}}&lt;/dateTime-test>
                     &lt;date-test>{{$variable[3] instance of xs:date}}&lt;/date-test>
                     &lt;time-test>{{$variable[4] instance of xs:time}}&lt;/time-test>
                     &lt;year-month-duration-test>{{$variable[5] instance of xs:yearMonthDuration}}&lt;/year-month-duration-test>
                     &lt;day-time-duration-test>{{$variable[6] instance of xs:dayTimeDuration}}&lt;/day-time-duration-test>
                     &lt;float-test>{{$variable[7] instance of xs:float}}&lt;/float-test>
                     &lt;double-test>{{$variable[8] instance of xs:double}}&lt;/double-test>
                     &lt;decimal-test>{{$variable[9] instance of xs:decimal}}&lt;/decimal-test>
                     &lt;gyear-month-test>{{$variable[10] instance of xs:gYearMonth}}&lt;/gyear-month-test>
                     &lt;gyear-test>{{$variable[11] instance of xs:gYear}}&lt;/gyear-test>
                     &lt;gmonth-day-test>{{$variable[12] instance of xs:gMonthDay}}&lt;/gmonth-day-test>
                     &lt;gday-test>{{$variable[13] instance of xs:gDay}}&lt;/gday-test>
                     &lt;gmonth-test>{{$variable[14] instance of xs:gMonth}}&lt;/gmonth-test>
                     &lt;boolean-test>{{$variable[15] instance of xs:boolean}}&lt;/boolean-test>
                     &lt;base64-test>{{$variable[16] instance of xs:base64Binary}}&lt;/base64-test>
                     &lt;hex-test>{{$variable[17] instance of xs:hexBinary}}&lt;/hex-test>
                     &lt;anyURI-test>{{$variable[18] instance of xs:anyURI}}&lt;/anyURI-test>
                     &lt;qname-test>{{$variable[19] instance of xs:QName}}&lt;/qname-test>
                  &lt;/tests>
               </p:inline>
            </p:with-input>
         </p:xquery>
      </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:pattern>
            <s:rule context="/">
               <s:assert test="tests">Root element is not 'tests'.</s:assert>
               <s:assert test="tests/untyped-test/text()='true'">$variable[1] is not xs:untypedAtomic.</s:assert>
               <s:assert test="tests/dateTime-test/text()='true'">$variable[2] is not xs:dateTime.</s:assert>
               <s:assert test="tests/date-test/text()='true'">$variable[3] is not xs:date.</s:assert>
               <s:assert test="tests/time-test/text()='true'">$variable[4] is not xs:time.</s:assert>
               <s:assert test="tests/year-month-duration-test/text()='true'">$variable[5] is not xs:yearMonthDuration.</s:assert>
               <s:assert test="tests/day-time-duration-test/text()='true'">$variable[6] is not xs:dayTimeDuration.</s:assert>
               <s:assert test="tests/float-test/text()='true'">$variable[7] is not xs:float</s:assert>
               <s:assert test="tests/double-test/text()='true'">$variable[8] is not xs:double</s:assert>
               <s:assert test="tests/decimal-test/text()='true'">$variable[9] is not xs:decimal</s:assert>
               <s:assert test="tests/gyear-month-test/text()='true'">$variable[10] is not xs:gYearMonth</s:assert>
               <s:assert test="tests/gyear-test/text()='true'">$variable[11] is not xs:gYear</s:assert>
               <s:assert test="tests/gmonth-day-test/text()='true'">$variable[12] is not xs:gMonthDay</s:assert>
               <s:assert test="tests/gday-test/text()='true'">$variable[13] is not xs:gDay</s:assert>
               <s:assert test="tests/gmonth-test/text()='true'">$variable[14] is not xs:gMonth</s:assert>
               <s:assert test="tests/boolean-test/text()='true'">$variable[15] is not xs:boolean</s:assert>
               <s:assert test="tests/base64-test/text()='true'">$variable[16] is not xs:base64Binary</s:assert>
               <s:assert test="tests/hex-test/text()='true'">$variable[17] is not xs:hexBinary</s:assert>
               <s:assert test="tests/anyURI-test/text()='true'">$variable[18] is not xs:anyURI</s:assert>
               <s:assert test="tests/qname-test/text()='true'">$variable[19] is not xs:QName</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
</t:test>