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

Re: Difficulty with document() and for-each scope

Subject: Re: Difficulty with document() and for-each scope
From: "Deborah Pickett" <debbiep-list-xsl@xxxxxxxxxx>
Date: Mon, 16 Jun 2008 17:04:03 +1000 (EST)
Re:  Difficulty with document() and for-each scope
On Mon, June 16, 2008 15:15, Adam Nielsen wrote:
>   <xsl:for-each select="document('')//me:month">
[...]
>     <!-- This template never gets applied -->
>     <xsl:apply-templates select="key('by-month', $month)">

It might be because key() selects only nodes in the document containing
the context node, which you've made into the stylesheet itself with your
xsl:for-each.  So there are no nodes matching /items/item to be selected.

I'm guessing that you are stuck using XSLT 1.0, because you don't need to
do the document('') shenanigans in XSLT 2.0, so the latter's
three-argument version of key() likely won't help.  You could wrap the
above-quoted xsl:apply-templates in another xsl:for-each that puts the
context node back to the document that you want to process:

<xsl:variable name="item-document" select="/"/>
<xsl:for-each select="document('')//me:month">
  ...
  <xsl:for-each select="$item-document">
    <xsl:apply-templates select="key('by-month', $month)">
    ...
  </xsl:for-each>
</xsl:for-each>

but it's starting to look a tad messy.

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.