Issue Details (XML | Word | Printable)

Key: XALANJ-2293
Type: Bug Bug
Status: Resolved Resolved
Resolution: Duplicate
Priority: Critical Critical
Assignee: Unassigned
Reporter: R
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XalanJ2

Error counting nodes when using a variable

Created: 21/Apr/06 06:16 PM   Updated: 11/Dec/07 04:57 PM
Return to search
Component/s: Xalan
Affects Version/s: 2.7
Fix Version/s: 2.7.1

Time Tracking:
Not Specified

Issue Links:
Duplicate
 
Reference
 

Fix priority: fp5
Resolution Date: 12/Jul/06 02:09 AM


 Description  « Hide
Consider the following XML file:

---------------------------------------------------
<xmldata>
    <value/>
    <value/>
</xmldata>
---------------------------------------------------


Consider the following XSL file:

---------------------------------------------------
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:variable name="doc" select="xmldata"/>

<xsl:template match="xmldata">

<html>
  <head/>
  <body>
  
   Number of elements: <xsl:value-of select="count($doc/value)"/>
   <br/>
   Number of elements: <xsl:value-of select="count($doc/value)"/>
   <br/>
  </body>
</html>

</xsl:template>
</xsl:stylesheet>
---------------------------------------------------

As you can see, the output should be an html page showing the total number of elements twice. However, this is the output:

---------------------------------------------------
Number of elements: 2
Number of elements: 4
---------------------------------------------------

Now consider the following XSL file:

---------------------------------------------------
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="xmldata">

<xsl:variable name="doc" select="."/>

<html>
  <head/>
  <body>
  
   Number of elements: <xsl:value-of select="count($doc/value)"/>
   <br/>
   Number of elements: <xsl:value-of select="count($doc/value)"/>
   <br/>
  </body>
</html>

</xsl:template>
</xsl:stylesheet>
---------------------------------------------------

Now the output is correct:

---------------------------------------------------
Number of elements: 2
Number of elements: 2
---------------------------------------------------

Comparing the two XSL files, the only diference is that the "doc" variable is declared outside or inside the template.

Thank you!

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henry Zongaro added a comment - 12/Jul/06 02:09 AM
This appears to be a duplicate of XALANJ-2204.

Brian Minchau added a comment - 12/Jul/06 10:59 PM
Henry Zongaro also found that when run with xalan interpretive
the problem does not exist in the latest development code,
but does exist in the 2.7.0 release.

So this fix should be picked up with the next release of xalan.
This issue was triaged on July 11, 2006.

Brian Minchau added a comment - 31/Oct/06 04:44 AM
Ricotta,
The fix in XALANJ-2204 has been re-worked, and that issue is once again resolved, so
this issue should also be resolved now. Please confirm that it works for you.

Brian Minchau added a comment - 11/Dec/07 04:57 PM
Would the originator of this issue please verify that this issue is fixed in the 2.7.1 release, by adding a comment to this issue, so that we can close this issue.

A lack of response by February 1, 2008 will be taken as consent that we can close this resolved issue.

Regards,
Brian Minchau