Closed Bug 303855 Opened 19 years ago Closed 19 years ago

Incorrect position() in xsl:apply-templates on loading XML file with style sheet in Firefox

Categories

(Firefox :: General, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 231715

People

(Reporter: ycao, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Firefox/1.0.6

The position() in xsl:apply-templates is not 1,2,3... but 2,4,6...
eg:
<xsl:template match="ROW">
	<xsl:value-of select="position()"/><br/>
</xsl:template>

Reproducible: Always

Steps to Reproduce:
1.Save the following to 01.xml
*******
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="01.xsl"?>
<ROWSET>
<ROW/>
<ROW/>
<ROW/>
</ROWSET>
*******

2.Save the following to 01.xsl
*******
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="UTF-8" method="html"/>

<xsl:template match="/">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>

<body>
	<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="ROWSET">
	<xsl:for-each select="ROW">
		<xsl:value-of select="position()"/><br/>
	</xsl:for-each>
	<hr/>
	<xsl:apply-templates />
</xsl:template>

<xsl:template match="ROW">
	<xsl:value-of select="position()"/><br/>
</xsl:template>

</xsl:stylesheet>
*******

3.Open 01.xml in Firefox
Actual Results:  
1
2
3
------------
2
4
6

Expected Results:  
1
2
3
------------
1
2
3

MS IE doesn't meet this issue.
Related to/duplicate of Core bug 267292, Core bug 274544 and/or Core bug 231715?
This is not a bug, only because text nodes are also computed. Though it seems
strange, but it is accordding spec.
Besides remove all whitespace(eg. line break between elements), You can try
xsl:strip-space.

*** This bug has been marked as a duplicate of 231715 ***
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.