- From: Michael Kay <mike@saxonica.com>
- Date: Fri, 7 Oct 2016 08:34:18 +0100
- To: Abel Braaksma <abel.braaksma@xs4all.nl>
- Cc: Public XSLWG <public-xsl-wg@w3.org>
The status quo in the spec is that you're not allowed to do any dynamic evaluation if the stylesheet contains any static errors, and that would include (I think) a dynamic error in the evaluation of a static expression. Having said that, we're probably going to start introducing user-selectable JIT compilation options that might defer static analysis of some constructs until they are first used, whether the spec allows it or not. We're spending too much time repeatedly compiling DocBook stylesheets that contain 500 template rules designed to process elements that don't actually appear in your source document. Michael Kay Saxonica > On 7 Oct 2016, at 00:04, Abel Braaksma <abel.braaksma@xs4all.nl> wrote: > > In many places in the spec we mention or hint that a processor is not required to evaluate an unused variable. How does this work for static parameters and variables? Do we require them to be processed? I browsed through the use-when and shadow attribute sections but couldn't readily find this. > > This may be important, for instance to detect static errors resulting from the dynamic evaluation of static expressions. > > Example: > > <xsl:variable name="x" use-when="1 div 0 eq 0" /> > > A processor may statically know that this variable is never used. Is it allowed to forego the error and process the stylesheet regardless? I'm inclined to say no, and that static expressions (use-when, static variables/parameters, shadow attributes) must *always* be evaluated. This follows from the notion of compile-time errors in other languages, of which static expressions are an extension. > > Other example: > > <xsl:mode name="m" _streamable="doc('settings.xml')/*/@streamable" /> > > It is possible that the document settings.xml contains an invalid setting for the streamable attribute. However, if a processor can statically infer that mode "m" is never used (it should be able to do so), then does it have to load settings.xml and process it? > > Again, I'm inclined to say yes: static errors must always be reported. > > It gets fuzzier with static variables/parameters, since we already say about variables that they only need to be evaluated when they are actually used: > > <xsl:variable name="foo" static="yes" select="xs:error('oh oh')"/> > > If no other static, or dynamic expression uses $foo, can it be ignored? Even here, I'd say: no, static expressions can never be ignored and should therefore be crafted more carefully than dynamic expressions. > > Note: no bug raised, I am not sure there's something wrong here. > > Cheers, > Abel > >
Received on Friday, 7 October 2016 07:34:51 UTC