[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: repeatedly calling a template triggered by data w

Subject: Re: repeatedly calling a template triggered by data within a parameter
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 28 Feb 2013 09:21:40 +0000
Re:  repeatedly calling a template triggered by data  w
Something like

<xsl:for-each select="1 to string-length($alphabet)">
  <xsl:call-template name="keyboard">
    <xsl:with-param name="letter" select="substring($alphabet, ., 1)"/>

perhaps?

Or if you want groups of six, something along the lines of

<xsl:for-each select="0 to ceiling(string-length($alphabet) div 6)">
  <xsl:call-template name="keyboard">
    <xsl:with-param name="letter" select="substring($alphabet, .+1, 6)"/>

You'll have to sort out the boundary conditions for yourself.

Michael Kay
Saxonica

On 28/02/2013 05:07, Mark Wilson wrote:
Hello,
I want to write a template that would, for each letter in some specified alphabet, call the following template to create a cell for an HTML table in the output document. Is there a way to set up something that would select each letter from an alphabet stored in a stylesheet parameter and call the 'keyboard' template? Since various alphabets have differing lengths and content, I was thinking of perhaps a string as the parameter. It would be very helpful to be able to trigger the template in groups of six to accommodate the <tr> elements.


I looked at XPath 'for' but could not see a means of triggering the 'keyboard' template.

Thanks,
Mark

<xsl:template name="keyboard">
<xsl:param name="letter"/>
<xsl:param name="this-page-name"/>
<xsl:choose>
<xsl:when test="not($this-page-name eq $letter)">
<xsl:variable name="file-name" select="concat(lower-case($letter),'.htm')"/>
<td>
<a href="{$file-name}">
<xsl:value-of select="$letter"/>
</a>
</td>
</xsl:when>
<xsl:otherwise>
<td class="current">
<xsl:value-of select="$letter"/>
</td>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

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.