Features: xquery_3_1

p:xquery 037 (AB)

Tests types of variables are set correctly (Part 2)

Test is expected to pass.

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0"
                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;
                  
                  <tests>
                     <integer-test>{{$variable[1] instance of xs:integer}}</integer-test>
                     <non-positive-integer-test>{{$variable[2] instance of xs:nonPositiveInteger}}</non-positive-integer-test>
                     <negative-integer-test>{{$variable[3] instance of xs:negativeInteger}}</negative-integer-test>
                     <long-test>{{$variable[4] instance of xs:long}}</long-test>
                     <int-test>{{$variable[5] instance of xs:int}}</int-test>
                     <short-test>{{$variable[6] instance of xs:short}}</short-test>
                     <byte-test>{{$variable[7] instance of xs:byte}}</byte-test>
                     <non-negative-integer-test>{{$variable[8] instance of xs:nonNegativeInteger}}</non-negative-integer-test>
                     <unsigned-long-test>{{$variable[9] instance of xs:unsignedLong}}</unsigned-long-test>
                     <unsigned-int-test>{{$variable[10] instance of xs:unsignedInt}}</unsigned-int-test>
                     <unsigned-short-test>{{$variable[11] instance of xs:unsignedShort}}</unsigned-short-test>
                     <unsigned-byte-test>{{$variable[12] instance of xs:unsignedByte}}</unsigned-byte-test>
                     <positive-integer-test>{{$variable[13] instance of xs:positiveInteger}}</positive-integer-test>
                  </tests>
               </p:inline>
      </p:with-input>
   </p:xquery>
</p:declare-step>

Result

<tests xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <integer-test>true</integer-test>
   <non-positive-integer-test>true</non-positive-integer-test>
   <negative-integer-test>true</negative-integer-test>
   <long-test>true</long-test>
   <int-test>true</int-test>
   <short-test>true</short-test>
   <byte-test>true</byte-test>
   <non-negative-integer-test>true</non-negative-integer-test>
   <unsigned-long-test>true</unsigned-long-test>
   <unsigned-int-test>true</unsigned-int-test>
   <unsigned-short-test>true</unsigned-short-test>
   <unsigned-byte-test>true</unsigned-byte-test>
   <positive-integer-test>true</positive-integer-test>
</tests>

Schematron checks

<s:schema xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
          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