Subject: Re: [xsl] Switching Between Two Column Mode and One Column Mode - Peek Ahead? From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 23 May 2005 16:36:49 +0100 |
> You got it exactly in the last form, let me include one special case: yes I think that's the same as the example I gave (but with 2 rather than 4 being long) <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:template match="x"> <table> <xsl:apply-templates select="item[1]"/> </table> </xsl:template> <xsl:template match="item"> <xsl:choose> <xsl:when test="(string-length(.) > 4 or string-length(following-sibling::item[1])> 4)"> <tr> <td colspan="2"> <xsl:value-of select="."/> </td> </tr> <xsl:apply-templates select="following-sibling::item[1]"/> </xsl:when> <xsl:otherwise> <tr> <td> <xsl:value-of select="."/> </td> <td> <xsl:value-of select="following-sibling::item[1]"/> </td> </tr> <xsl:apply-templates select="following-sibling::item[2]"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> <x> <item>1</item> <item>2</item> <item>333333</item> <item>4</item> <item>5</item> <item>6</item> </x> <?xml version="1.0" encoding="utf-8"?> <table> <tr> <td>1</td> <td>2</td> </tr> <tr> <td colspan="2">333333</td> </tr> <tr> <td>4</td> <td>5</td> </tr> <tr> <td>6</td> <td/> </tr> </table> <x> <item>1</item> <item>2 2 2 2 </item> <item>3</item> <item>4</item> <item>5</item> <item>6</item> </x> <table> <tr> <td colspan="2">1</td> </tr> <tr> <td colspan="2">2 2 2 2 </td> </tr> <tr> <td>3</td> <td>4</td> </tr> <tr> <td>5</td> <td>6</td> </tr> </table> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Switching Between Two Col, kent | Thread | RE: [xsl] Switching Between Two Col, kent |
Re: [xsl] configuring a conditional, Bruce D'Arcus | Date | RE: [xsl] Switching Between Two Col, kent |
Month |