0

我正在使用 xerces 使用两个 xsl 文件处理 xml,并且在我的 xsl:for-each 循环中得到错误的结果,
for 循环返回 8 个结果而不是 4 个结果
如何调试此错误?
谢谢你的帮助!

xml:

<Updates>
  <update_record displayTimestamp="2013-03-08 11:44:00">
    <user>MNM3322</user>
  </update_record>
  <update_record displayTimestamp="2013-03-08 11:45:00">
    <user>MNM3323</user>
  </update_record>
  <update_record displayTimestamp="2013-03-08 11:46:00">
    <user>MNM3322</user>
  </update_record>
  <update_record displayTimestamp="2013-03-08 11:47:00">
    <user>MNM3325</user>
  </update_record>
  <LatestUpdate/>
</Updates>

第一个.xsl

<xsl:variable name="updates" select="//Updates"/>

第二个.xsl

<xsl:variable name="updatesCount"
              select="count($updates/update_record)"/>

<xsl:include href="first.xsl"/>

<xsl:value-of select="$updatesCount"/>  this gives correct result (4)
<xsl:for-each select="$updates/update_record"> this gives incorrect output (8 rows instead of 4)
       <xsl:value-of select="position()"/>
</xsl:for-each>
4

1 回答 1

0

发现问题。它的 XALAN 错误

请参见此处:
如果在全局变量中使用递归模板,则循环变量/参数参考

https://issues.apache.org/jira/browse/XALANJ-2430
谢谢!

于 2013-04-18T14:40:33.457 回答