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

making balanced 2 columns from single column of data (

Subject: making balanced 2 columns from single column of data (also examples from D Pawsons Site and Others found flag errors)
From: "SANWAL, ABHISHEK (HP-Houston)" <abhishek.sanwal@xxxxxx>
Date: Sun, 14 Sep 2003 23:14:56 -0500
xsl 2 columns
http://www.biglist.com/lists/xsl-list/archives/200001/msg00129.html
http://www.dpawson.co.uk/xsl/sect2/N7450.html#d4e64
(making balanced 2 columns)

They both flag errors when trying to test to see if they work at all.
I get the following error message when I run the following stuff in
XMLSpy 

This file is not well-formed: & expected. Save anyway. 

And it points to the location where the <= operator is present below in
the XSL.

Of course when I execute it flags Xpath errors in XMLSpy as well as
MSXSL 4.0

What seems to be the mistake in this example.

Input 
<?xml version='1.0'?>
<TASKS>
  <TASK>
    <COMPONENTS>
      <COMPONENT>A</COMPONENT>
      <COMPONENT>B</COMPONENT>
      <COMPONENT>C</COMPONENT>
      <COMPONENT>D</COMPONENT>
      <COMPONENT>E</COMPONENT>
      <COMPONENT>F</COMPONENT>
      <COMPONENT>G</COMPONENT>
      <COMPONENT>H</COMPONENT>
      <COMPONENT>I</COMPONENT>
      <COMPONENT>J</COMPONENT>
      <COMPONENT>K</COMPONENT>
    </COMPONENTS>
  </TASK>
</TASKS>

xsl

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" indent="yes"/>

<xsl:template match="/">

  <xsl:apply-templates/>
</xsl:template>
<xsl:template match="TASKS/TASK/COMPONENTS">
  <xsl:variable name="t-size" select="count(COMPONENT)"/>
  <xsl:variable name="half" select="ceiling($t-size div 2)"/>
   
<TABLE>
  <xsl:for-each select="COMPONENT[position() <= $half]">
   <xsl:variable name="here" select="position()"/>
    <TR>
      <TD><xsl:value-of select="."/></TD>
      <TD>
        <xsl:choose>
	  <xsl:when test="../COMPONENT[$here+$half]">
	    <xsl:value-of select="../COMPONENT[$here+$half]"/>
          </xsl:when>
          <xsl:otherwise></xsl:otherwise>
        </xsl:choose>
      </TD>
    </TR>
  </xsl:for-each>
</TABLE>

</xsl:template>
</xsl:stylesheet>


Abhishek Sanwal
HP - Houston Campus
abhishek.sanwal@xxxxxx


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