Subject: Re: [xsl] Node set From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 7 Feb 2001 09:20:54 +0000 |
Hi Yue, > If I have the order in XML file like: > title1,title2,title3,title4,title5 > > The order we should display MAY be: > title1,title3,title2(on the left column) > title5,title4(on the right column) > again, any title element may not be in the XML file, means if I don't find > title3, I should display: > title1,title2(on the left column) > title5,title4(on the right column) >From this description, you could use: <table> <xsl:variable name="top-row" select="count(title1 | title2 | title3)" /> <xsl:variable name="bottom-row" select="count(title4 | title5)" /> <xsl:if test="$top-row"> <tr> <xsl:apply-templates select="title1" /> <xsl:apply-templates select="title3" /> <xsl:apply-templates select="title2" /> <xsl:if test="$bottom-row > $top-row"> <td /> </xsl:if> </tr> </xsl:if> <xsl:if test="title4 or title5"> <tr> <xsl:apply-templates select="title5" /> <xsl:apply-templates select="title4" /> <xsl:if test="$top-row > $bottom-row"> <td /> <xsl:if test="$top-row - $bottom-row = 2"> <td /> </xsl:if> </xsl:if> </tr> </xsl:if> </table> With the following template giving the cells for each title (it will only be processed if there *is* such a title): <xsl:template match="title1 | title2 | title3 | title4 | title5"> <td><xsl:value-of select="." /></td> </xsl:template> Of course, you may not have covered all possible scenarios in your description. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Node set, YueMa | Thread | [xsl] Selecting a set of nodes, noelia crespo |
[xsl] Table breaks AND multi-level , Rob Wygand | Date | Re: [xsl] XInclude in Cocoon, David Carlisle |
Month |