This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Problem with keys in for-each (?)
- To: xsl-list at lists dot mulberrytech dot com
- Subject: [xsl] Problem with keys in for-each (?)
- From: Don Bruey <dbruey at CreativeSolutions dot com>
- Date: Tue, 13 Mar 2001 14:10:23 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
In the following XSLT, I have a key() function called to look up a specific
element in the key. If I call this alone, as it is in the first line of the
template for "/", it works and I get the output I expect. If I do the EXACT
same thing within the loop, I get no output as a result of the
apply-templates. The for-each loop is getting executed the appropriate
number of times. The results are the same for MSXML3 and Saxon. Any ideas?
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:xbrl="http://www.xbrl.org/core/2000-07-31/metamodel"
xmlns:xsd ="http://www.w3.org/1999/XMLSchema">
<xsl:variable name="taxonomy" select="document('AlteredTaxonomy.xml')" />
<xsl:key name="itemKey" match="//*[local-name() = 'item']"
use="ancestor-or-self::*[@type][1]/@type" />
<xsl:template match="/">
<!-- this apply-templates call works fine and calls the template below
correctly -->
<xsl:apply-templates select="key('itemKey',
'ci:entityInformation.businessDescription')" />
<xsl:for-each select="$taxonomy//element" >
<!-- xsl:number does output something the number of times I would
expect,
so I know this loop is getting executed -->
<xsl:number /><BR/>
<!-- nothing is generated by this call this time -
it's exactly the same as the above apply-templates call...
Why? -->
<xsl:apply-templates select="key('itemKey',
'ci:entityInformation.businessDescription')" />
</xsl:for-each>
</xsl:template>
<xsl:template match="*">
do something here
</xsl:template>
I want to create a variable within the for-each loop with the correct key
and
look that up - but since I can't get past this issue, I can't use the
variable as the key either,
which is why this bizarre hardcoded XSLT is what I currently am working
with.
Thanks.
Don
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list