Subject: Re: [xsl] repeatedly calling a template triggered by data within a parameter From: Michael Kay <mike@xxxxxxxxxxxx> Date: Thu, 28 Feb 2013 09:21:40 +0000 |
<xsl:for-each select="1 to string-length($alphabet)"> <xsl:call-template name="keyboard"> <xsl:with-param name="letter" select="substring($alphabet, ., 1)"/>
<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)"/>
Michael Kay Saxonica
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] repeatedly calling a template, Mark Wilson | Thread | Re: [xsl] repeatedly calling a temp, Mark Wilson |
[xsl] repeatedly calling a template, Mark Wilson | Date | Re: [xsl] repeatedly calling a temp, Mark Wilson |
Month |