You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Nathan Pride <np...@wavo.com> on 2000/08/09 17:05:20 UTC
Xalan bug: sorting on position() within for-each or apply-templates
Hi,
I came across this while trying to reverse document order of some
nodes.
When using for-each or apply-templates the results are 1 - 20, if I
use the node value they are ordered correctly. I checked the position()
call, when the position() is evaluated within <xsl:sort> the position()
value is always 1. I assume this has the wrong context. Unfortunately I
got lost trying to remedy this, hopeful someone more familiar with the
code can help.
Thanks
Nathan
Xalan versions tried are xalan-j_1_1 and xalan-j_1_2_D01
These are the files I used for the test case:
XML:
<?xml version="1.0"?>
<doc>
<b>1</b><b>2</b><b>3</b><b>4</b><b>5</b>
<b>6</b><b>7</b><b>8</b><b>9</b><b>10</b>
<b>11</b><b>12</b><b>13</b><b>14</b><b>15</b>
<b>16</b><b>17</b><b>18</b><b>19</b><b>20</b>
</doc>
XSL:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="doc">
<xsl:output method="html" indent="yes"/>
<html>
<head><title>Wahhh</title></head>
<body>
<table>
<!--
<xsl:apply-templates select="b">
<xsl:sort select="position()" data-type="number"
order="descending"/>
</xsl:apply-templates >
-->
<xsl:for-each select="b">
<xsl:sort select="position()" data-type="number"
order="descending"/>
<tr>
<td>Position: <xsl:value-of select="position()"/></td>
<td>Value: <xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="b">
<tr>
<td>Position: <xsl:value-of select="position()"/></td>
<td>Value: <xsl:value-of select="."/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
---