RE: [xsl] Switching Between Two Column Mode and One Column Mode - Peek Ahead?

Subject: RE: [xsl] Switching Between Two Column Mode and One Column Mode - Peek Ahead?
From: "kent" <kent@xxxxxxxxxxxxxxxxx>
Date: Mon, 23 May 2005 18:31:55 +0100
Beautiful, thanks a mil.

Here is the your example, modified for a real feed, if someone needs it:

<xsl:for-each select="rss/channel/item">
     
<xsl:choose>
<xsl:when test="(string-length(description) &gt; 2500  or
string-length(following-sibling::description[1])&gt; 2500)"> 
<tr> 
<td colspan="2"> 
<firstcase><xsl:value-of disable-output-escaping="yes"  select="."/>
</firstcase>
</td> 
</tr>
 <xsl:apply-templates disable-output-escaping="yes"
select="following-sibling::description[1]"/>
</xsl:when>
<xsl:otherwise>
<tr>
<td>
<xsl:value-of disable-output-escaping="yes" select="."/>
</td>
<td>
<xsl:value-of disable-output-escaping="yes"
select="following-sibling::item/description[1]"/>
</td>
</tr>
<xsl:apply-templates select="following-sibling::item/description[2]"/>
</xsl:otherwise>
</xsl:choose>


</xsl:for-each>

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx] 
Sent: Monday, May 23, 2005 4:37 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Switching Between Two Column Mode and One Column Mode -
Peek Ahead?



> 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(.) &gt; 4  or
string-length(following-sibling::item[1])&gt; 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