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

RE: key() and document() - scoping problem?

Subject: RE: key() and document() - scoping problem?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 19 Dec 2006 10:30:44 -0000
RE:  key() and document() - scoping problem?
The key() function searches the document that contains the context node.

In 1.0, you need to change the context node, which you can do using
xsl:for-each.

In 2.0, you can use the third argument of key() to determine which document
is searched.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Bryn Lewis [mailto:blewis@xxxxxxxxxx] 
> Sent: 19 December 2006 08:16
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  key() and document() - scoping problem?
> 
> I have defined a key, then use its value in the following xsl 
> (xslt v.1):
> 
> <span class="x">
> 	<xsl:value-of select="count(key('key2_1', 'general'))" 
> /> </span> <xsl:for-each 
> select="document(string($options))/options/option">
> 	<span class="y">
> 		<xsl:value-of select="count(key('key2_1', 
> 'general'))" />
>     	</span>
> </xsl:for-each>
> 
> Results in this:
> 
> <span class="x">4</span>
> <span class="y">0</span>
> 
> I would expect to get a '4' in both cases.
> 
> The document referred to is referenced correctly and I would 
> be using it to specify the key value required.
> 
> The document seems to throw the key out of scope, but I dont 
> see how to correct that.
> 
> thanks, Bryn
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.15.24/592 - Release 
> Date: 18/12/2006 1:45 PM
>  
> The contents of this email and any attachments are 
> confidential and may be privileged or otherwise protected 
> from disclosure.
> 
> If you are not the intended recipient of this email please 
> notify the sender immediately, delete the email and any 
> attachments from your system and do not print, distribute, 
> store, commercialise or act on any information it contains.

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.