|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Why I want to change the value of a variable.
The fact that variables can't vary in XSLT means that it is often easier
to use recursion than for-loops, with the notable exception (I believe)
of situations where you need alphabetic sorting.
In your case you need both changing variables and sorting, so the
solution involves both recursion and a for loop.
It's also worth browsing the XPATH spec for useful functions...
Francis.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<HTML>
<HEAD><TITLE>People list</TITLE></HEAD>
<BODY>
<xsl:call-template name="heading">
<xsl:with-param name="abc" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
/>
</xsl:call-template>
</BODY>
</HTML>
</xsl:template>
<xsl:template name="heading">
<xsl:param name="abc" />
<xsl:variable name="letter" select="substring($abc,1,1)" />
<CENTER>- <xsl:value-of select="$letter" /> -</CENTER><BR/>
<xsl:for-each select="//PEOPLE[starts-with(NAME, $letter)]">
<xsl:sort select="NAME"/>
<xsl:sort select="FIRST_NAME"/>
<xsl:value-of select="concat(FIRST_NAME, ' ', NAME)"/>
<BR/>
</xsl:for-each>
<xsl:if test="string-length($abc) != 1">
<xsl:call-template name="heading">
<xsl:with-param name="abc" select="substring($abc, 2)" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








