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

Re: Organizing list of items in HTML table

Subject: Re: Organizing list of items in HTML table
From: "Paul Tyson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 27 Sep 2001 14:01:16 -0700
organizing lists
Ooops, you need an additional test before filling the last row, in case the
number of columns divides the number of images evenly.  See correction
below.

--Paul

----- Original Message -----
From: "Paul Tyson" <paul@xxxxxxxxxxxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, September 27, 2001 1:32 PM
Subject: Re:  Organizing list of items in HTML table


> These few templates appear to do what you want.  Modify the 'image'
template
> to get what you want in each table cell.  Adjust the 'numCols' parameter
for
> different number of columns.
>
>   <xsl:output method="html"/>
>   <xsl:param name="numCols" select="3"/>
>
>   <xsl:template match="imageList">
>     <table>
>       <xsl:call-template name="make-rows"/>
>     </table>
>   </xsl:template>
>
>   <xsl:template match="image">
>     <xsl:text>&#10;</xsl:text>
>     <td>
>       <img>
>         <xsl:attribute name="src">
>           <xsl:value-of select="./imageName"/>
>         </xsl:attribute>
>       </img>
>     </td>
>   </xsl:template>
>
>   <xsl:template name="make-rows">
>     <xsl:param name="n" select="1"/>
>     <xsl:choose>
>       <xsl:when test="$n &gt; count(image)"/>
>       <xsl:otherwise>
>         <xsl:text>&#10;</xsl:text>
>         <tr>
>           <xsl:apply-templates
>             select="image[position() &gt;= $n and
>                     position() &lt; $n + $numCols]"/>
>           <xsl:if test="not(image[position() &gt;= $n + $numCols])">

*** Correction: above line should be:
          <xsl:if test="not(image[position() &gt;= $n + $numCols]) and
                            count(image) mod $numCols">
*** end of correction.

>             <xsl:call-template name="fill-row">
>               <xsl:with-param name="num-empty"
>                 select="$numCols - count(image) mod $numCols"/>
>             </xsl:call-template>
>           </xsl:if>
>         </tr>
>         <xsl:call-template name="make-rows">
>           <xsl:with-param name="n" select="$n + $numCols"/>
>         </xsl:call-template>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:template>
>
>   <xsl:template name="fill-row">
>     <xsl:param name="num-empty"/>
>     <xsl:choose>
>       <xsl:when test="$num-empty = 0"/>
>       <xsl:otherwise>
>         <td></td>
>         <xsl:call-template name="fill-row">
>           <xsl:with-param name="num-empty" select="$num-empty - 1"/>
>         </xsl:call-template>
>       </xsl:otherwise>
>     </xsl:choose>
>   </xsl:template>
>
> Good luck,
> Paul Tyson
> paul at precisiondocuments dot com
>



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


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-2011 All Rights Reserved.