Question

I am processing xml using two xsl files using xerces, and getting wrong results in my xsl:for-each loop,
the for loop return 8 results instead of 4 results
How can debug this error?
Thanks for your help!

The 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>

first.xsl

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

second.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>
Was it helpful?

Solution

Found the issue. its XALAN Bug

See here:
Circular variable/parameter reference if recursive template is used in global variable

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top