[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: What's evaluated first: @select or xsl:with-param?

Subject: Re: What's evaluated first: @select or xsl:with-param?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 18 Oct 2010 16:40:58 +0100
Re:  What's evaluated first: @select or xsl:with-param?
The specification leaves this implementation-defined. Since the values of the parameters are the same for every node processed, it's a reasonably strategy for the processor to evaluate the parameters before knowing how many selected nodes there are, though I guess an even better strategy would be to do it lazily when the first selected node is found.

But note also that this is a type error, and that type errors can even be reported at compile-time, even if the apply-templates is never executed. This could happen for example if the variable $b can be evaluated at compile time and its value is known statically to be an empty sequence.

Michael Kay
Saxonica

On 18/10/2010 16:19, Vladimir Nesterovsky wrote:
Hello!

I've seen a code like this:
----------
<xsl:variable name="a" as="element()?" select="..."/>
<xsl:variable name="b" as="element()?" select="..."/>

<xsl:apply-templates select="$a">
   <xsl:with-param name="b" tunnel="yes" as="element()" select="$b"/>
</xsl:apply-templates>
----------

It fails with an error:
"An empty sequence is not allowed as the value of parameter $b".

What is interesting is that the value of $a is an empty sequence,
so the code could potentially work, provided processor evaluated $a first,
and decided not to evaluate xsl:with-param.

Whether the order of evaluation of @select and xsl:with-param is specified

by the standard or it's an implementation defined?

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.