XSLT:显示已过滤 XML 记录集的唯一行
我有一个记录集,正在对特定字段进行过滤(即 Manager ="Frannklin")。现在我想根据另一个字段(客户端)对该过滤记录集的结果进行分组。我似乎无法让慕尼黑分组正常工作。
有什么想法吗?
蒂亚!
CG
我的过滤器如下所示:
模板
< br>
<
xsl:template match="Row" mode="g1000a">
客户端:
我得到的结果
客户端:测试版
客户端:测试版
客户端:测试版
客户:伽玛
客户:
我想要达美结果
客户端:测试版
客户:伽玛
客户端:Delta
示例记录集<行>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,您需要一个复合键。
此转换:
当应用于提供的 XML 文档时,会产生所需的正确结果:
You need a compound key for this.
This transformation:
when applied on the provided XML document, produces the wanted, correct result: