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://ift.tt/tCZ8VR">
<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:
2
blah 4
blah 6
blah 8
blah
Why does it skip the uneven numbers?
No comments:
Post a Comment