qtspecs
qtspecs copied to clipboard
XSLT: debugging template rule selection
The biggest headache when debugging XSLT stylesheets is working out which template rules have been invoked in response to an xsl:apply-templates
instruction (I'm hitting this frustration right now with the qtspecs build stylesheets...). The xsl:message
instruction is unhelpful here, because if the "wrong" template rule is firing, you don't know where to add the message. And the only other standardised debugging aids are fn:trace()
and xsl:assert
, which don't help either.
I propose an attribute on xsl:apply-templates
, xsl:apply-imports
, and xsl:next-match
: trace=yes|no. If enabled, execution of the instruction causes a message to be output (as if by xsl:message) identifying the rule that is invoked, in an implementation-defined way. In the case that a built-in template rule is invoked, the message should indicate this, and any implicit apply-templates performed by the built-in rule should be evaluated as if it specified trace="yes". It is "recommended" that the message output should identify the stylesheet module, line number, match pattern, and mode, if the information is available, and should also include a representation of the item that is being processed by the instruction, for example the node kind and name.