File: Data.xml
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="Transform.xslt" ?>
<nodeTester type="referral">
<function>
<name>position() function</name>
</function>
<text>
This function helps find the position of a node in the node
list.
</text>
</nodeTester>
File: Transform.xslt
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" indent="no" />
<xsl:template match="nodeTester">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="text">
<xsl:variable name="myPositionVariable" select="position()" />
NodeList position =
<xsl:value-of select="$myPositionVariable" />
</xsl:template>
</xsl:stylesheet>
Output:
position() function
NodeList position =
4
|