Hi,
If the following xml is a good example of your document:
<z:foo xmlns:z="foo">
<z:row ID="1" Parent_ID="0"></z:row>
<z:row ID="2" Parent_ID="0"></z:row>
<z:row ID="3" Parent_ID="1"></z:row>
<z:row ID="4" Parent_ID="3" Exclude_YN = 'P'></z:row>
<z:row ID="5" Parent_ID="2" Exclude_YN = 'C'></z:row>
</z:foo>
the following xsl produces the output:
Row Id: 1 contains P
Row Id: 2 contains C
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:z="foo">
<xsl:key name="rows-by-parent" match="z:row" use="@Parent_ID" />
<xsl:template match="/">
<xsl:apply-templates select="z:foo/z:row[(_at_)Parent_ID='0']" />
</xsl:template>
<xsl:template match="z:row[(_at_)Parent_ID='0']">
Row Id: <xsl:value-of select="@ID" />
<xsl:apply-templates select="key('rows-by-parent', @ID)" />
<br />
</xsl:template>
<xsl:template match="z:row[(_at_)Parent_ID!='0']">
<xsl:choose>
<xsl:when test="@Exclude_YN='P'"> contains P </xsl:when>
<xsl:when test="@Exclude_YN='C'"> contains C </xsl:when>
</xsl:choose>
<xsl:apply-templates select="key('rows-by-parent', @ID)" />
</xsl:template>
</xsl:stylesheet>
Hope that helps!
-Mike
On Wed, 13 Oct 2004 11:58:38 +0200, Werner, Wolfgang
<mail(_at_)wolfgang-werner(_dot_)net> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- -------- Original Message --------
Subject: XSL Grouping and Filtering
Date: Tue, 12 Oct 2004 13:07:42 -0400
From: Renuka Singh (Contractor) <Renuka(_dot_)Singh(_at_)MBNA(_dot_)COM>
To: 'mail(_at_)wolfgang-werner(_dot_)net'
<mail(_at_)wolfgang-werner(_dot_)net>
Hi..
I've been trying to post a question to the
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com and I am unable to do so,
because the
Exchange server here is set to sent out messages in xhtml format (which
cannot be changed by an individual user). I came across your email in
one of these messages. I have the following problem adn would really
appreciate if you could help me out.
I am currently using xsl keys in my xsl document, to group child nodes
under
parent nodes. This is being run against an ADO recordset so my key looks
something like this :
<xsl:key name="rows-by-parent" match="z:row" use="@Parent_ID" />
My hierarchy can go several levels deep (about 10 levels are currently
supported). If any one of the children (n levels deep) of a level 1
parent
node(@Parent_ID = 0), has a variable @Exclude_YN = 'P' or Exclude_YN = 'C',
then I wish to display a text message next to that Parent Node, in my HTML
document.
I don't know how to apply the filter to child nodes n levels deep in the
hierarchy using an xsl:key. I am using keys to group currently.
Any suggestion is highly appreciated.
Thank you.
RS
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBbPxNqjaicDyx8o8RApn/AJ47WgdFMAFSrTn7WYVgTaXbcsL4gACeNs1m
u8C1FruO+RPx+SSDKHNi7Yk=
=/TDp
-----END PGP SIGNATURE-----
--+------------------------------------------------------------------
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>
--+--
--
[row.filter]