template-params-001

Test that the p:xslt step accepts template-parameters and template-tunnel-parameters options. (Not yet part of XProc.)

Test is expected to pass.

The pipeline

<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
   <p:import href="https://xmlcalabash.com/ext/library/railroad.xpl"/>
   <p:output port="result" sequence="true"/>
   <p:xslt template-name="main"
           template-parameters="map{'two':2}"
           template-tunnel-parameters="map{'t': 'tunneled', 'u': 'unused'}">
      <p:with-input port="source">
         <p:empty/>
      </p:with-input>
      <p:with-input port="stylesheet">
         <xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema"
                         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         exclude-result-prefixes="xs" version="3.0">
            <xsl:output method="xml" encoding="utf-8"
                        indent="no"/>
            <xsl:template name="main">
               <xsl:param name="one" select="1"/>
               <xsl:param name="two" select="'NaN'"/>
               <xsl:param name="t" tunnel="yes"
                          select="'absent'"/>
               <doc one="{{$one}}" two="{{$two}}"
                    t="{{$t}}"/>
            </xsl:template>
         </xsl:stylesheet>
      </p:with-input>
   </p:xslt>
</p:declare-step>

Result

<doc xmlns:cx="http://xmlcalabash.com/ns/extensions"
     xmlns:t="http://xproc.org/ns/testsuite/3.0" one="1" two="2" t="tunneled"/>

Schematron checks

<s:schema 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="doc">The root is wrong.</s:assert>
      </s:rule>
   </s:pattern>
   <s:pattern>
      <s:rule context="/doc">
         <s:assert test="@one = 1">The attribute ‘one’ is incorrect.</s:assert>
         <s:assert test="@two = 2">The attribute ‘two’ is incorrect.</s:assert>
         <s:assert test="@t = 'tunneled'">The attribute ‘t’ is incorrect.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

15 Mar 2026, Norm Tovey-Walsh
Created test.