[xslt] position() yielding doubled values???



Hi,

I recently took over the maintenance of the Debian package of libxslt
and am now working my way through all the outstanding bug reports filed
against the Debian package.

One of the bug reports claims that given the XML file

    <?xml version="1.0" ?>

    <data>
      <table>
	<tr>
	  <td>test11</td>
	  <td>test22</td>
	</tr>
	<tr>
	  <td>test21</td>
	  <td>test22</td>
	</tr>
	<tr>
	  <td>test31</td>
	  <td>test32</td>
	</tr>
      </table>
    </data>

and the XSLT stylesheet

    <?xml version="1.0" encoding="iso-8859-1" ?>

    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
      xmlns="http://www.w3.org/TR/REC-html40";>
      <xsl:output 
	  method="html" 
	  media-type="text/html" 
	  doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" 
	  encoding="utf-8"/>
      <xsl:template match="/">
	<xsl:apply-templates />
      </xsl:template>
      <xsl:template match="table">
	<table><xsl:apply-templates /></table>
      </xsl:template>
      <xsl:template match="tr">
	<tr>
	  <td>Position: <xsl:value-of select="position()"/></td>
	  <xsl:apply-templates />
	</tr>
      </xsl:template>
      <xsl:template match="td">
	<td><xsl:apply-templates /></td>
      </xsl:template>
    </xsl:stylesheet>

the following incorrect output is generated:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

      <table>
	<tr>
	<td>Position: 2</td>
	  <td>test11</td>
	  <td>test22</td>
	</tr>
	<tr>
	<td>Position: 4</td>
	  <td>test21</td>
	  <td>test22</td>
	</tr>
	<tr>
	<td>Position: 6</td>
	  <td>test31</td>
	  <td>test32</td>
	</tr>
      </table>

with the "Position" values being doubled.  I ran the same files through
sablotron and xalan, and I got exactly the same result.  It seems rather
unlikely to me that all three would implement position() wrong.

I don't know XSLT well enough yet to say whether this is indeed an actual
error.  Any thoughts?

Thanks,
Ardo
-- 
Ardo van Rangelrooij
home email: ardo@debian.org
home page:  http://people.debian.org/~ardo
GnuPG fp:   3B 1F 21 72 00 5C 3A 73  7F 72 DF D9 90 78 47 F9



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]