p:xquery 037 (AB)

Tests types of variables are set correctly (Part 2)

Test ab-xquery-037.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:integer('42'),                xs:nonPositiveInteger('-10'),                xs:negativeInteger('-42'),                xs:long('42'),                xs:int('42'),                xs:short('42'),                xs:byte('42'),                xs:nonNegativeInteger('42'),                xs:unsignedLong('42'),                xs:unsignedInt('42'),                xs:unsignedShort('42'),                xs:unsignedByte('42'),                xs:positiveInteger('42')                )}">
      <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;integer-test&gt;{{$variable[1] instance of xs:integer}}&lt;/integer-test&gt;
                     &lt;non-positive-integer-test&gt;{{$variable[2] instance of xs:nonPositiveInteger}}&lt;/non-positive-integer-test&gt;
                     &lt;negative-integer-test&gt;{{$variable[3] instance of xs:negativeInteger}}&lt;/negative-integer-test&gt;
                     &lt;long-test&gt;{{$variable[4] instance of xs:long}}&lt;/long-test&gt;
                     &lt;int-test&gt;{{$variable[5] instance of xs:int}}&lt;/int-test&gt;
                     &lt;short-test&gt;{{$variable[6] instance of xs:short}}&lt;/short-test&gt;
                     &lt;byte-test&gt;{{$variable[7] instance of xs:byte}}&lt;/byte-test&gt;
                     &lt;non-negative-integer-test&gt;{{$variable[8] instance of xs:nonNegativeInteger}}&lt;/non-negative-integer-test&gt;
                     &lt;unsigned-long-test&gt;{{$variable[9] instance of xs:unsignedLong}}&lt;/unsigned-long-test&gt;
                     &lt;unsigned-int-test&gt;{{$variable[10] instance of xs:unsignedInt}}&lt;/unsigned-int-test&gt;
                     &lt;unsigned-short-test&gt;{{$variable[11] instance of xs:unsignedShort}}&lt;/unsigned-short-test&gt;
                     &lt;unsigned-byte-test&gt;{{$variable[12] instance of xs:unsignedByte}}&lt;/unsigned-byte-test&gt;
                     &lt;positive-integer-test&gt;{{$variable[13] instance of xs:positiveInteger}}&lt;/positive-integer-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/integer-test/text()='true'">$variable[1] is not xs:integer</s:assert>
         <s:assert test="tests/non-positive-integer-test/text()='true'">$variable[2] is not xs:nonPositiveInteger</s:assert>
         <s:assert test="tests/negative-integer-test/text()='true'">$variable[3] is not xs:negativeInteger</s:assert>
         <s:assert test="tests/long-test/text()='true'">$variable[4] is not xs:long</s:assert>
         <s:assert test="tests/int-test/text()='true'">$variable[5] is not xs:int</s:assert>
         <s:assert test="tests/short-test/text()='true'">$variable[6] is not xs:short</s:assert>
         <s:assert test="tests/byte-test/text()='true'">$variable[7] is not xs:byte</s:assert>
         <s:assert test="tests/non-negative-integer-test/text()='true'">$variable[8] is not xs:nonNegativeInteger</s:assert>
         <s:assert test="tests/unsigned-long-test/text()='true'">$variable[9] is not xs:unsignedLong</s:assert>
         <s:assert test="tests/unsigned-int-test/text()='true'">$variable[10] is not xs:unsignedInt</s:assert>
         <s:assert test="tests/unsigned-short-test/text()='true'">$variable[11] is not xs:unsignedShort</s:assert>
         <s:assert test="tests/unsigned-byte-test/text()='true'">$variable[12] is not xs:unsignedByte</s:assert>
         <s:assert test="tests/positive-integer-test/text()='true'">$variable[13] is not xs:positive-integer</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

29 Oct 2026, Achim Berndzen

Initial commit