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

Re: Can keys go out of scope?

Subject: Re: Can keys go out of scope?
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Fri, 1 Mar 2002 12:59:35 -0800
keys score
If $template is a result-tree-fragment, then yes keys can go out of scope.  
Essentially, an RTF is a separate document, and each document has its own set 
of keys (the same applies when you for-each or apply-templates with the 
document() function).

What's happening is that your apply-templates is selecting nodes from another 
document (the RTF).  So in the other template way down the line, the context 
*document* (similar to the context node) is also the RTF.  Since that 
document has a different set of keys than the original source document, it 
doesn't work.

Sorry, but I don't think there is an easier way to do that, other than, 
perhaps, switching the context-document back to the original source document:

<xsl:for-each select="$current">
  <xsl:value-of select="key('scores', @ScoreRef)"/>
</xsl:for-each>

(I haven't tested that)

On Friday 01 March 2002 10:19, TSchutzerWeissmann@xxxxxxxxxxxxxxxx wrote:
> I know keys can't go out of scope, I just want to know why I'm having to do
> this:
>
>  <xsl:template match="Billcode">
>    <xsl:variable name="current" select="."/>
>    <xsl:apply-templates
>      select="$template/sc:static/*" mode="static">
>      <xsl:with-param name="current" select="$current"/>
>      <xsl:with-param name="score" select="key('scores',@ScoreRef)"/>     #I
> shouldn't need to do this
>     </xsl:apply-templates>
>  </xsl:template>
>
>
> The key only gets used at the other end of some chained templates, and I
> would have hoped to be able to do this:
> <xsl:value-of select="key('scores',$current/@ScoreRef)"/>,
>
> given that I'm passing the Billcode element down the chain in the $current
> parameter. I've been through this n times, it even works on a different
> stylesheet. I've tested the value of $current/@ScoreRef at every step of
> the way, and it's what it was in the first template shown above. Any idea
> what's going on (or, (@~!#  as Captain Haddock would say)?
>
> Thanks for your help
> Tom
>
>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

-- 
Peter Davis
And now for something completely different.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.