Re: [xsl] XSL:key and Column grouping

Subject: Re: [xsl] XSL:key and Column grouping
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 01 Feb 2005 15:42:11 -0500
Hi David,

Yes, you're almost there. In order to use key() as flexibly as you need to, you have to "back out" a bit.

Try modifying this bit of code:

<xsl:for-each select="key('map', mapunits/maps)[position() mod 3 = 1]">
  <tr valign="top" style="width:100%">
    <xsl:apply-templates select=".|following-sibling::maps[position() &lt;
3]"/>
  </tr>
</xsl:for-each>

to read something like:


<xsl:variable name="key-value" select="mapunits/maps"/>
<xsl:for-each select="key('map', $key-value)">
  <xsl:if select="position() mod 3 = 1">
    <xsl:variable name="pos" select="position()"/>
    <tr valign="top" style="width:100%">
      <xsl:apply-templates select=". |
         key('map', $key-value)[$pos+1] |
         key('map', $key-value)[$pos+2]"/>
      <!-- and maybe you'll want code here to provide
           blank cells when you don't have exact multiples of three -->
    </tr>
  </xsl:if>
</xsl:for-each>

I hope it's more or less self-explanatory....

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread