[xslt] template for last element does not match



Hi everybody,

I could not find any hint, why this does not work for me.
Please help!

Translating

<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<table>
  <row>...</row>
  <row>...</row>
  <row>...</row>
</table>


with the stylesheet:


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="1.0">

<xsl:template match="table">
  <xsl:message>table containing <xsl:value-of
select="count(child::row)"/> rows</xsl:message>
  <xsl:apply-templates select="child::row"/>
</xsl:template>

<xsl:template match="row">
  <xsl:message>row No.: <xsl:value-of select="position()"/> of
<xsl:value-of select="last()"/></xsl:message>
</xsl:template>

<xsl:template match="row[position()=last()]">
  <xsl:message>LAST row</xsl:message>
</xsl:template>

</xsl:stylesheet>


results in:


[tschrader ben-nevis]$ xsltproc --novalid --noout test.xsl test.xml
table containing 4 rows
row No.: 1 of 3
row No.: 2 of 3
row No.: 3 of 3

So, could anyone tell, why the template for the last row does
not match?

I'm using libxslt 1.1.12 on Fedora.

Thanks very much for any hint.

--

Thomas Schrader
mailto tschrader at aeccom com



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