xsl-list
[Top] [All Lists]

Re: [xsl] repeatedly calling a template triggered by data within a parameter

2013-02-28 11:14:20
Thank you Michael!

On 28/02/2013 02:21, Michael Kay wrote:

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>



--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





--
Mark Wilson
Knihtisk Publishing



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>