xsl-list
[Top] [All Lists]

RE: [xsl] key() and document() - scoping problem?

2006-12-19 03:31:07
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(_at_)nps(_dot_)org(_dot_)au] 
Sent: 19 December 2006 08:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] 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.

--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>