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

Re: A general <xsl:key> question.

Subject: Re: A general <xsl:key> question.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 5 Dec 2002 17:11:49 +0000
Re:  A general <xsl:key> question.
Hi Edward,

> Do keys have to be used within a context in which the associated
> nodes exist?

Yes. The context node at the point where you use the key (with the
key() function) has to be a node in the document that you're
searching.

Usually this means that you should create a variable to hold the key
value that you want to search for, then switch into the context of the
document that you want to search in (using <xsl:for-each>) before
using the key.

I can't tell precisely what's going to work with your code, but
something like:

<xsl:key name="PageKey" match="/gnsl:Results/gnsl:Table/gnsl:Row"
         use="((count(preceding-sibling::*) div $RowsPerPage) + 1)" />

<xsl:variable name="results" select="/" />

<xsl:template name="ProcessPageRows">
   <xsl:variable name="PageNum" select="@PageNum" />
   <xsl:variable name="StartRow" select="@StartRow" />
   <xsl:variable name="EndRow" select="@EndRow" />

   <xsl:if test="$NumberOfRows">
      <xsl:for-each select="$results">
        <xsl:apply-templates select="key('PageKey',$PageNum)" />
      </xsl:for-each>
   </xsl:if>
</xsl:template>

You need to set the $results variable to being a node set containing a
single node in the document in which the gnsl:Row elements that you're
interested in are held.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.