p:xquery 036 (AB)

Tests types of variables are set correctly (Part 1)

Test ab-xquery-036.xml is expected to pass.

It requires the following features: xquery_3_1.

The 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&gt;
                     &lt;untyped-test&gt;{{$variable[1] instance of xs:untypedAtomic}}&lt;/untyped-test&gt;
                     &lt;dateTime-test&gt;{{$variable[2] instance of xs:dateTime}}&lt;/dateTime-test&gt;
                     &lt;date-test&gt;{{$variable[3] instance of xs:date}}&lt;/date-test&gt;
                     &lt;time-test&gt;{{$variable[4] instance of xs:time}}&lt;/time-test&gt;
                     &lt;year-month-duration-test&gt;{{$variable[5] instance of xs:yearMonthDuration}}&lt;/year-month-duration-test&gt;
                     &lt;day-time-duration-test&gt;{{$variable[6] instance of xs:dayTimeDuration}}&lt;/day-time-duration-test&gt;
                     &lt;float-test&gt;{{$variable[7] instance of xs:float}}&lt;/float-test&gt;
                     &lt;double-test&gt;{{$variable[8] instance of xs:double}}&lt;/double-test&gt;
                     &lt;decimal-test&gt;{{$variable[9] instance of xs:decimal}}&lt;/decimal-test&gt;
                     &lt;gyear-month-test&gt;{{$variable[10] instance of xs:gYearMonth}}&lt;/gyear-month-test&gt;
                     &lt;gyear-test&gt;{{$variable[11] instance of xs:gYear}}&lt;/gyear-test&gt;
                     &lt;gmonth-day-test&gt;{{$variable[12] instance of xs:gMonthDay}}&lt;/gmonth-day-test&gt;
                     &lt;gday-test&gt;{{$variable[13] instance of xs:gDay}}&lt;/gday-test&gt;
                     &lt;gmonth-test&gt;{{$variable[14] instance of xs:gMonth}}&lt;/gmonth-test&gt;
                     &lt;boolean-test&gt;{{$variable[15] instance of xs:boolean}}&lt;/boolean-test&gt;
                     &lt;base64-test&gt;{{$variable[16] instance of xs:base64Binary}}&lt;/base64-test&gt;
                     &lt;hex-test&gt;{{$variable[17] instance of xs:hexBinary}}&lt;/hex-test&gt;
                     &lt;anyURI-test&gt;{{$variable[18] instance of xs:anyURI}}&lt;/anyURI-test&gt;
                     &lt;qname-test&gt;{{$variable[19] instance of xs:QName}}&lt;/qname-test&gt;
                  &lt;/tests&gt;
               </p:inline>
      </p:with-input>
   </p:xquery>
</p:declare-step>

Schematron validation

<s:schema xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <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>

Revision history

29 Oct 2026, Achim Berndzen

Initial commit