Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1861 Params passed automatically through next-match #1875

Merged
merged 2 commits into from
Mar 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 50 additions & 7 deletions specifications/xslt-40/src/xslt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14930,6 +14930,12 @@ return $tree =?> depth()]]></eg>
</div2>
<div2 id="apply-imports">
<head>Overriding Template Rules</head>
<changes>
<change issue="1861">
The <elcode>xsl:apply-imports</elcode> and <elcode>xsl:next-match</elcode> instructions automatically
pass supplied parameters to the overridden template rule.
</change>
</changes>
<?element xsl:apply-imports?>
<?element xsl:next-match?>
<p>A <termref def="dt-template-rule">template rule</termref> that is being used to
Expand Down Expand Up @@ -15069,9 +15075,32 @@ return $tree =?> depth()]]></eg>

<p>If a matching template rule <var>R</var> is found, then the result
of the <elcode>xsl:next-match</elcode> or <elcode>xsl:apply-imports</elcode> instruction is the
result of invoking <var>R</var>, with the values of parameters being set using the child
<elcode>xsl:with-param</elcode> elements as described in <specref ref="with-param"/>.
The template rule <var>R</var> is evaluated with the same <termref def="dt-focus"/> as the <elcode>xsl:next-match</elcode>
result of invoking <var>R</var>. The parameters that are passed to <var>R</var> are as follows:</p>

<ulist>
<item><p>All parameters explicitly set using <elcode>xsl:with-param</elcode>
child elements (see <specref ref="with-param"/>).</p></item>
<item><p>If the <termref def="dt-effective-version"/> of the <elcode>xsl:next-match</elcode>
or <elcode>xsl:apply-imports</elcode> instruction is 4.0 or greater, then
all non-tunnel parameters that were supplied in the invocation of the
current template rule, excluding any whose names match the names of
parameters appearing in child <elcode>xsl:with-param</elcode> elements.</p></item>
<item><p>All <termref def="dt-tunnel-parameter">tunnel parameters</termref>
as described in <specref ref="tunnel-params"/>.</p></item>
</ulist>

<note>
<p>The implicit passing of non-tunnel parameters is new in XSLT 4.0, and happens only if
<code>[xsl:]version</code> is set to 4.0 (or greater) on the instruction, or on some ancestor element
in the stylesheet. There may be cases where this
change introduces a backward incompatibility: specifically, if the invoked template rule declares a default
value for an optional parameter, it will now take the implicitly passed value rather than the
default value. The 3.0 behavior can be therefore be retained by setting <code>version="3.0"</code>
on the <elcode>xsl:next-match</elcode> or <elcode>xsl:apply-imports</elcode> instruction.</p>
</note>

<p>The template rule <var>R</var> is evaluated with the same <termref def="dt-focus"/>
as the <elcode>xsl:next-match</elcode>
or <elcode>xsl:apply-imports</elcode> instruction. The <termref def="dt-current-template-rule"/>
changes to be <var>R</var>. The <termref def="dt-current-mode"/> does not change.
</p>
Expand All @@ -15091,9 +15120,6 @@ return $tree =?> depth()]]></eg>
<p>If no matching template rule is found that satisfies these criteria, the built-in
template rule for the context item is used (see
<specref ref="built-in-rule"/>).</p>
<p>An <elcode>xsl:apply-imports</elcode> or <elcode>xsl:next-match</elcode> instruction
may use <elcode>xsl:with-param</elcode> child elements to pass parameters to the
chosen <termref def="dt-template-rule">template rule</termref> (see <specref ref="with-param"/>). It also passes on any <termref def="dt-tunnel-parameter">tunnel parameters</termref> as described in <specref ref="tunnel-params"/>.</p>
<p>
<error spec="XT" type="dynamic" class="DE" code="0560">
<p>It is a <termref def="dt-dynamic-error"> dynamic error</termref> if
Expand Down Expand Up @@ -39631,6 +39657,10 @@ return ($m?price - $m?discount)</eg>
invoke an XSLT 2.0 processor in preference to an XSLT 3.0 processor when the
stylesheet specifies <code>version="2.0"</code>, in which case any use of new 3.0
constructs will be rejected.</p>
<p>There are cases where setting <code>[xsl:]version</code> to a value less than
4.0 affects the behavior of an XSLT 4.0 stylesheet: see <specref ref="incompatibilities"/>.
However these are sufficiently minor that they do not warrant the introduction of a
separate conformance option.</p>
</note>
</div2>
<div2 id="streaming-feature">
Expand Down Expand Up @@ -40314,7 +40344,7 @@ See <loc href="http://www.w3.org/TR/xhtml11/"/>



<inform-div1 id="incompatibilities" diff="add" at="2022-01-01">
<inform-div1 id="incompatibilities">
<head>Incompatibilities with XSLT 3.0</head>
<p>This section lists all known incompatibilities with XSLT 3.0, that is, situations
where a stylesheet that is error-free
Expand Down Expand Up @@ -40346,6 +40376,19 @@ See <loc href="http://www.w3.org/TR/xhtml11/"/>
priority. This rule has not been carried forward into XSLT 4.0: instead, the priority
of the rule is taken as being the highest priority of any of the alternatives.</p>
</item>
<item>
<p>In XSLT 4.0, an <elcode>xsl:apply-imports</elcode> or <elcode>xsl:next-match</elcode>
instruction automatically passes on the values of any non-tunnel parameters that were
present in its own invocation. This means that the template rule invoked by
<elcode>xsl:apply-imports</elcode> or <elcode>xsl:next-match</elcode>, if it declares
a default value for such a parameter, will take the implicitly-supplied value in
preference to the default value.</p>
<p>This change in the specification applies only if the <termref def="dt-effective-version"/>
of the <elcode>xsl:apply-imports</elcode> or <elcode>xsl:next-match</elcode> is 4.0 or greater.
This means that 3.0 behavior can be retained by adding the attribute <code>version="3.0"</code>
to the instruction, or to some ancestor element (for example, the <elcode>xsl:stylesheet</elcode>
or <code>xsl:transform</code> element).</p>
</item>



Expand Down