w3c / qtspecs

XSLT and XQuery Specifications - the source used to build the specs, and the errata
Other
30 stars 25 forks source link

[xslt30] Dynamic context while evaluating template parameters #13

Open michaelhkay opened 4 years ago

michaelhkay commented 4 years ago

The context for evaluation of the default value of a template parameter is underspecified. For example, what happens if the sequence constructor contained within xsl:param invokes xsl:next-match?

In fact, I don't think the spec has a clear answer to the question of what the focus is when evaluating such a default value. For xsl:call-template the focus of the caller and callee are the same, so it's not really a problem. For apply-templates, they are different, and we don't clearly say. For xsl:iterate we're explicit that the dynamic context for xsl:param is the context of the callee; but that doesn't really work for variable references, because the "scope of variables" section says that the scope of a variable declared in xsl:param includes following-sibling xsl:param elements - so how can they be part of the static context of a following-sibling xsl:param without also being part of the dynamic context?

As regards xsl:next-match, which is what led me here:

§6.8 says "Whenever a template rule is chosen as a result of evaluating xsl:apply-templates, xsl:apply-imports, or xsl:next-match, the template rule becomes the current template rule for the evaluation of the rule’s sequence constructor." The xsl:param isn't part of the sequence constructor, so this would suggest it uses the caller's current template rule.

However §6.8 also says "These rules ensure that when xsl:apply-imports or xsl:next-match is called, the context item is the same as when the current template rule was invoked." But it seems unclear what the context item for evaluating the default value of an xsl:param in a template rule should be.