I have a similar problem as this guy:
using position() function in xslt
But I dont need the numbering, I just want to understand the way it works:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<a>blah</a>
<a>blah</a>
<a>blah</a>
<a>blah</a>
</test>
for this input, the following stylesheet:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="select">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a">
<xsl:value-of select="position()"/><br/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
outputs:
<html><body>
2<br>blah
4<br>blah
6<br>blah
8<br>blah
</body></html>
Why does it skip the uneven numbers?
<xsl:template match="select">
in your stylesheet? Your input doesn't have an element namedselect
.