Re: two column list using FOs?

Subject: Re: two column list using FOs?
From: "Nikolai Grigoriev" <grig@xxxxxxx>
Date: Thu, 4 May 2000 00:36:14 +0400
Philip Marden wrote:

> Using FOs, I would like to lay out a list into 2 columns so that half
> the list items are in the first column and the remaining are in the
> second column.  Moreover, this should work for an arbitrary number of
> list items.  What is a direct way of coding this in XSL to produce
> FOs?

There's no special for XSL FO, the same HTML trick applies: draw a table of two
cells and put the first half of items into the first cell and the rest to the
second. Here's an (untested) sample for the last XSL FO draft (2000-03-27):

<xsl:template match="OL">
   <xsl:variable name="threshold" select="(count(LI) + 1) div 2"/>

   <fo:table>
      <fo:column column-width="..."/> <!-- first column -->
      <fo:column column-width="..."/> <!-- second column -->
      <fo:table-body>
         <fo:table-row>
            <fo:table-cell> <!-- First column -->
               <fo:list-block>
                  <xsl:apply-templates 
                       select="LI[position() &lt;=threshold]"/>
               </fo:list-block>
            </fo:table-cell>
            <fo:table-cell> <!-- Second column -->
               <fo:list-block>
                  <xsl:apply-templates 
                       select="LI[position() &gt; $threshold]"/>
               </fo:list-block>
            </fo:table-cell>
         </fo:table-row>
      <fo:table-body>
   </fo:table>
</xsl:template>

<xsl:template match="OL/LI">
   <fo:list-item>
      <fo:list-item-label end-indent="label-end()">
          <xsl:number format="1."/>
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">
          <xsl:apply-templates/>
      </fo:list-item-body>
   </fo:list-item>
</xsl:template>

Regards,
Nikolai Grigoriev

RenderX






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread