topical media & game development
basic-xml-07-Books.xsl / xsl
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head>
<title>This shows the context position and context size.</title>
</head>
<body>
<h3>Context position and context size demo.</h3>
<xsl:apply-templates select="/Book/Chapter" />
</body>
</html>
</xsl:template>
<xsl:template match="Chapter">
<xsl:if test="position()=2">
<p>When the context node is the second <b>Chapter</b> element node then</p>
<p>the context position is <xsl:value-of select="position()" /></p>
<p>and the context size is <xsl:value-of select="last()" />.</p>
<p>The text the <b> Chapter</b> element node contains is '<xsl:value-of select="." />'.</p>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.