|
Subject: [xsl] Pattern: Replicating Key Table Construction for Debugging From: "W. Eliot Kimber" <eliot@xxxxxxxxxx> Date: Tue, 19 Feb 2002 20:49:48 -0600 |
This should have been obvious, but it took me a while to figure it out
and I know a lot of people are struggling with key-based processing:
There's no direct way to see what the entries in a table are (e.g., the
equivalent of Hastable.getKeySet() in Java). However, you can easily
replicate what the key table is doing and sanity check what's happening.
All you do is a for-each from the root that uses the same select rule as
the key.
For example, if your key declaration is:
<xsl:key name="primary"
match="index.marker"
use="normalize-space(concat(primary/@sortas,
primary[not(@sortas)]))"/>
Then to see what is actually going into the table, just do this:
<xsl:for-each select="//index.marker">
<xsl:message>key='<xsl:value-of
select="normalize-space(concat(primary/@sortas,
primary[not(@sortas)]))"/>'</xsl:message>
</xsl:for-each>
This should print out the equivalent of all the entries in the table.
You can also capture the key value and do a lookup in the table to see,
for example, how many of that entry are in the table under that key.
<xsl:for-each select="//index.marker">
<xsl:variable name="tempkey">
<xsl:value-of
select="normalize-space(concat(primary/@sortas,
primary[not(@sortas)]))"/>
<xsl:variable>
<xsl:message>key='<xsl:value-of select="$tempkey"/>'</xsl:message>
<xsl:message> <xsl:value-of select="count(key('primary', $tempkey))/>
items found
</xsl:message>
</xsl:for-each>
Cheers,
Eliot
--
W. Eliot Kimber, eliot@xxxxxxxxxx
Consultant, ISOGEN International
1016 La Posada Dr., Suite 240
Austin, TX 78752 Phone: 512.656.4139
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Restarting the numbering , Jeni Tennison | Thread | Re: [xsl] Pattern: Replicating Key , Jeni Tennison |
| [xsl] Restarting the numbering sequ, gary fong | Date | Re: [xsl] xslerator - does anything, bernwardhanssen |
| Month |