[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.

Subject: Re: Why I want to change the value of a variable.
From: Francis Norton <francis@xxxxxxxxxxx>
Date: Tue, 26 Oct 1999 12:57:22 +0100
xslt change param value
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.