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

Re: Second of two consecutive call-template instructio

Subject: Re: Second of two consecutive call-template instructions appears to affect the first?
From: Sebastian Tennant <sebyte@xxxxxxxxxxxxxxx>
Date: Wed, 15 Mar 2006 13:53:52 +0000
fault call template
"Michael Kay" <mike@xxxxxxxxxxxx> wrote:

> This template:
>
>   <xsl:template name="does-image-flickr">
>     <xsl:choose><!-- photo is a flickr link -->
>       <xsl:when test="/page/images/image[@name=$name]/flickr">
>         <a href="{/page/images/image[@name=$name]/flickr}">
>           <xsl:call-template name="pass-image-params" />
>
> contains two refences to the variable $name, which isn't in scope in this
> template. If you want it to be available in this template, you need to pass
> it as a parameter.
>
> It looks as if Xalan isn't reporting this error if it occurs in a template
> that isn't called. The XSLT 1.0 spec isn't very precise about which errors
> are static errors and which are dynamic, so that's probably conformant:
XSLT
> 2.0 makes it mandatory to report this as a static error.
>
> Michael Kay
> http://www.saxonica.com/


Sorry Michael, I still don't get it.  The 'does-image-flickr' template
is called both times, i.e., whether the following instruction is a
call to 'write-caption' or not, so why should $name need to be
declared in one instance and not in another? ($name is a parameter by
the way).

What's more, look at the template 'pass-image-params'.  This is called
(using call-template) without explicitly passing it any parameters,
and it successfully passes parameters defined in its caller to the
'image' template (using apply-templates).  Its very raison-d'C*tre is
to cut down on the repetition of lines of code, because the
conditional logic requires me to pass these parameters to the 'image'
template from four different places.

No doubt my understanding is at fault, but I could have sworn blind
using call-template preserved the local scope as well as the current
node list.  Using it (rather than apply-templates) to provide this
functionality has worked for me time and time again thus far.

sdt

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.