This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
This test uses a template wit a required parameter, whose value is not referenced. Is it mandatory to raise an error in this case? <xsl:template match="doc"> <xsl:param name="x" required="yes"/> <xsl:value-of select="2"/> </xsl:template> [ERR XTDE0700] In other cases, it is a non-recoverable dynamic error if the template that is invoked declares a template parameter with required="yes" and no value for this parameter is supplied by the calling instruction.
No, you do not need to reference the parameter. But you do need to pass the parameter on in xsl:apply-templates/xsl:with-param. If you don't, raise XTDE0700. Whether or not the parameter is referenced in the body of the template is not relevant (according to the current state of the spec). Do you want to raise a spec-bug for this?
I think you may have misunderstood me. <xsl:template match="doc"> <xsl:param name="x" required="yes"/> <xsl:value-of select="2"/> </xsl:template> does not reference $x. Therefore $x need never be evaluated. Therefore I can determine that this template either raises an error (XTDE0700), or returns 2. I am therefore permitted to avoid raising the dynamic error.
I think as the error is currently defined you have to raise it unconditionally. I don't think one can appeal to XPath errors and optimization rules for this.
OK thanks. Happy to close.
I was happy, and then I read this. "Because different implementations may optimize execution of the stylesheet in different ways, the detection of dynamic errors is to some degree implementation-dependent. In cases where an implementation is able to produce the final result trees without evaluating a particular construct, the implementation is never required to evaluate that construct solely in order to determine whether doing so causes a dynamic error. For example, if a variable is declared but never referenced, an implementation may choose whether or not to evaluate the variable declaration, which means that if evaluating the variable declaration causes a dynamic error, some implementations will signal this error and others will not." So I think raising the error here is not required.
The problem is not with evaluation the variable: indeed, an optimizing processor does not need to evaluate a variable that is never referenced. The issue here is with invoking the template. If the caller does not provide this parameter, it is in error. I consider it similar to stylesheet functions. Take for instance: <xsl:function name="f:foo"> <xsl:param name="x" /> </xsl:function> The function body does nothing, $x is never evaluated, however, calling f:foo() (without a parameter) is illegal and will raise an exception, regardless of any optimization. Yes, you never have to evaluate the parameter. No, you must raise an error on the caller if it does not provide a required parameter. Same goes for xsl:param with required="yes".
Thanks for your response.