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

RE: Making balanced two-column tables from one-column data

Subject: RE: Making balanced two-column tables from one-column data
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Thu, 20 Jan 2000 08:56:05 +0100
two column table xslt
I thought this was a rather good article on XPath, by Norman Walsh: 


-----Original Message-----
From: Philip Borenstein [mailto:pb@xxxxxxxxxx]
Sent: Wednesday, January 19, 2000 7:35 PM
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: Making balanced two-column tables from one-column data

I have a solution to my problem, but it seems so un-XSLT-like, and ugly that
I'm sure there must be a better solution. i think that part of the problem
is that I just don't "get" XPaths. Pointers to good XPath learning resources
much appreciated.

I have the following XML:


I want to produce a two-column table like this:

  A   G
  B   H
  C   I
  D  J
  E  K

(The number of COMPONENTS may or may not be even.)

This is my XSL template for the COMPONENT element:

<xsl:template match="COMPONENTS">
  <P>There are <xsl:value-of select="count(COMPONENT)"/> components.</P>
     <xsl:variable name="h" select="round(count(COMPONENT) div 2)" />
     <xsl:for-each select="COMPONENT">
       <xsl:variable name="p" select="position()" /> 
       <xsl:if test="$h>=$p">
                  <TD><xsl:value-of select="../COMPONENT[position()=$p]"
                  <TD><xsl:value-of select="../COMPONENT[position()=$p+$h]"

This just strikes me as the wrong way to go about it.

--philip borenstein.

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

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

Current Thread


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.
First Name
Last Name
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-2013 All Rights Reserved.