XSLT: Display unique rows of filtered XML recordset
Posted
by Chris G.
on Stack Overflow
See other posts from Stack Overflow
or by Chris G.
Published on 2010-05-04T20:40:25Z
Indexed on
2010/05/04
22:58 UTC
Read the original article
Hit count: 344
xslt
|muenchian-grouping
I've got a recordset that I'm filtering on a particular field (i.e. Manager ="Frannklin"). Now I'd like to group the results of that filtered recordset based on another field (Client). I can't seem to get Muenchian grouping to work right.
Any thoughts?
TIA!
CG
My filter looks like this:
<xsl:key name="k1" match="Row" use="@Manager"/>
<xsl:param name="dvt_filterval">Frannklin</xsl:param>
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
<xsl:variable name="FilteredRowsAttr" select="$Rows[normalize-space(@*[name()=$FieldNameNoAtSign])=$dvt_filterval ]" />
Templates
<xsl:apply-templates select="$FilteredRowsAttr[generate-id() = generate-id(key('k1',@Manager))]" mode="g1000a">
</xsl:apply-templates>
<xsl:template match="Row" mode="g1000a">
Client: <xsl:value-of select="@Client"/>
</xsl:template>
Results I'm getting
Client: Beta
Client: Beta
Client: Beta
Client: Gamma
Client: Delta
Results I want
Client: Beta
Client: Gamma
Client: Delta
Sample recordset
<dsQueryResponse>
<Rows>
<Row Manager="Smith" Client="Alpha " Project_x0020_Name="Annapolis" PM_x0023_="00123" />
<Row Manager="Ford" Client="Alpha " Project_x0020_Name="Brown" PM_x0023_="00124" />
<Row Manager="Cronkite" Client="Beta " Project_x0020_Name="Gannon" PM_x0023_="00129" />
<Row Manager="Clinton, Bill" Client="Beta " Project_x0020_Name="Harvard" PM_x0023_="00130" />
<Row Manager="Frannklin" Client="Beta " Project_x0020_Name="Irving" PM_x0023_="00131" />
<Row Manager="Frannklin" Client="Beta " Project_x0020_Name="Jakarta" PM_x0023_="00132" />
<Row Manager="Frannklin" Client="Beta " Project_x0020_Name="Vassar" PM_x0023_="00135" />
<Row Manager="Jefferson" Client="Gamma " Project_x0020_Name="Stamford" PM_x0023_="00141" />
<Row Manager="Cronkite" Client="Gamma " Project_x0020_Name="Tufts" PM_x0023_="00142" />
<Row Manager="Frannklin" Client="Gamma " Project_x0020_Name="UCLA" PM_x0023_="00143" />
<Row Manager="Jefferson" Client="Gamma " Project_x0020_Name="Villanova" PM_x0023_="00144" />
<Row Manager="Carter" Client="Delta " Project_x0020_Name="Drexel" PM_x0023_="00150" />
<Row Manager="Clinton" Client="Delta " Project_x0020_Name="Iona" PM_x0023_="00151" />
<Row Manager="Frannklin" Client="Delta " Project_x0020_Name="Temple" PM_x0023_="00152" />
<Row Manager="Ford" Client="Epsilon " Project_x0020_Name="UNC" PM_x0023_="00157" />
<Row Manager="Clinton" Client="Epsilon " Project_x0020_Name="Berkley" PM_x0023_="00158" />
</Rows>
</dsQueryResponse>
© Stack Overflow or respective owner