【发布时间】:2011-12-08 18:32:21
【问题描述】:
我有一个 xml 文件,我需要使用 xsl:for-each-group 对其进行分组。一切正常,但问题出在元素末尾有空格时(例如<word>test </word> and <word>test</word>),但我需要将它们视为一组。
这是示例 xml 文件:
<u>
<s>
<w>this </w>
<w>is </w>
<w>a </w>
<w>test </w>
</s>
<s>
<w>this</w>
<w>is</w>
<w>a</w>
<w>test</w>
</s>
<u>
这是 xslt 代码
<xsl:for-each-group select="bncDoc/stext/div/u/s" group-by="w" >
<tr>
<td style="text-align: center;">
<xsl:value-of select="current-grouping-key()"/>
</td>
<td>
<xsl:value-of select="count(current-group())"/>
</td>
</tr>
</xsl:for-each-group>
有什么解决方法吗?
【问题讨论】:
-
如果您发布了您尝试生成的输出示例,将会很有帮助。目前尚不清楚您是否需要调整您的 select 语句或 group-by(或两者)。
-
我只需要调整group-by语句。
标签: xslt xslt-2.0 xslt-grouping