This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25874 - [XT30TS] error-code-268
Summary: [XT30TS] error-code-268
Status: CLOSED INVALID
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 Test Suite (show other bugs)
Version: 2nd Edition Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Abel Braaksma
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-23 11:56 UTC by Tim Mills
Modified: 2014-06-10 13:02 UTC (History)
1 user (show)

See Also:


Attachments

Description Tim Mills 2014-05-23 11:56:10 UTC
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.
Comment 1 Abel Braaksma 2014-05-23 14:54:46 UTC
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?
Comment 2 Tim Mills 2014-05-23 15:16:48 UTC
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.
Comment 3 Michael Kay 2014-05-23 15:37:11 UTC
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.
Comment 4 Tim Mills 2014-05-23 15:39:42 UTC
OK thanks.

Happy to close.
Comment 5 Tim Mills 2014-05-23 15:44:33 UTC
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.
Comment 6 Abel Braaksma 2014-05-23 16:30:00 UTC
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".
Comment 7 Tim Mills 2014-06-10 13:01:38 UTC
Thanks for your response.