[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] making balanced 2 columns from single column of data (also examples from D Pawsons Site and Others found flag errors)
Subject: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Get and change element at, Mukul Gandhi | Thread | RE: [xsl] making balanced 2 columns, Jarno . Elovirta |
Re: [xsl] Get and change element at, Mukul Gandhi | Date | Re: [xsl] Noob here: anyone using X, Rajendra S Rawat |
Month |