p:xquery 038 (AB)

Tests types of variables are set correctly (Part 3)

Test ab-xquery-038.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:string('text'),                xs:normalizedString('text'),                xs:token('text'),                xs:language('en'),                xs:NMTOKEN('text'),                xs:Name('name'),                xs:NCName('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;string-test&gt;{{$variable[1] instance of xs:string}}&lt;/string-test&gt;
                     &lt;normalized-string-test&gt;{{$variable[2] instance of xs:normalizedString}}&lt;/normalized-string-test&gt;
                     &lt;token-test&gt;{{$variable[3] instance of xs:token}}&lt;/token-test&gt;
                     &lt;language-test&gt;{{$variable[4] instance of xs:language}}&lt;/language-test&gt;
                     &lt;NMTOKEN-test&gt;{{$variable[5] instance of xs:NMTOKEN}}&lt;/NMTOKEN-test&gt;
                     &lt;name-test&gt;{{$variable[6] instance of xs:Name}}&lt;/name-test&gt;
                     &lt;ncname-test&gt;{{$variable[7] instance of xs:NCName}}&lt;/ncname-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/string-test/text()='true'">$variable[1] is not xs:string</s:assert>
         <s:assert test="tests/normalized-string-test/text()='true'">$variable[2] is not xs:normalizedString</s:assert>
         <s:assert test="tests/token-test/text()='true'">$variable[3] is not xs:token</s:assert>
         <s:assert test="tests/language-test/text()='true'">$variable[4] is not xs:language</s:assert>
         <s:assert test="tests/NMTOKEN-test/text()='true'">$variable[5] is not xs:NMTOKEN</s:assert>
         <s:assert test="tests/name-test/text()='true'">$variable[6] is not xs:Name</s:assert>
         <s:assert test="tests/ncname-test/text()='true'">$variable[7] is not xs:NCName</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

29 Oct 2026, Achim Berndzen

Initial commit