xsl-list
[Top] [All Lists]

Re: [xsl] Second of two consecutive call-template instructions appears to affect the first?

2006-03-15 08:23:20
"Michael Kay" <mike(_at_)saxonica(_dot_)com> wrote:

This template:

  <xsl:template name="does-image-flickr">
    <xsl:choose><!-- photo is a flickr link -->
      <xsl:when test="/page/images/image[(_at_)name=$name]/flickr">
        <a href="{/page/images/image[(_at_)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/

Well I'm stunned!

I've explicitly declared all the variables at the start of all the
templates and explicitly passed all the variables I want to pass in my
template call-template calls resulting in about 20 extra lines of
code... and it works!

The reason I'm stunned is not because it works, but because I could
have sworn it was working before.  Nay, it _was_ working, I tested it,
and it was workign _without_ all the explicit declarations and
parameter passes.  What's more, it seemed to make perfect
sense;  call-template preseves the local scope, apply-templates
doesn't.

Oh well, now I know it doesn't work like that, but I swear it almost
did!  Incredible!

Thanks all.

sdt


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--