|
Subject: Re: [xsl] [Fwd: XSL Grouping and Filtering] From: M G <row.filter@xxxxxxxxx> Date: Thu, 14 Oct 2004 10:05:02 +0200 |
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[@Parent_ID='0']" />
</xsl:template>
<xsl:template match="z:row[@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[@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@xxxxxxxxxxxxxxxxxxx> 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.Singh@xxxxxxxx>
> To: 'mail@xxxxxxxxxxxxxxxxxxx' <mail@xxxxxxxxxxxxxxxxxxx>
>
> Hi..
>
> I've been trying to post a question to the
> xsl-list@xxxxxxxxxxxxxxxxxxxxxx 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-----
>
>
--
[row.filter]
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] [Fwd: XSL Grouping and Filter, Werner, Wolfgang | Thread | [xsl] XEP 4.0 is released, Alexander Peshkov |
| RE: [xsl] FW: XSL calling Java prob, Manpreet Singh | Date | [xsl] How to sort?, Mike G |
| Month |