cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klaus Malorny <Klaus.Malo...@knipp.de>
Subject Re: conditional </tr><tr> generation ???
Date Tue, 20 Jun 2000 15:46:25 GMT
Zvi wrote:
> 
> sorry again,
> 
> this one wrong too,
> you need to use nested loops, or use one loop and actually generate each table raw...
> again sorry for wrong answers...
> 
> Zvi wrote:
> 
> > sorry :))
> >
> > I was thinking about something like this, not tried, but u need to think in this
> > direction...
> >
> > <table>
> >      <xsl:for-each select="group">
> >         <xsl:case>
> >              <xsl:when test="position() mod 4 = 0">
> >                  <tr>
> >                      <td> blablabla </td>
> >                   </tr>
> >              </xsl:when>
> >             <xsl:otherwise>
> >                    <td> blablabla </td>
> >             </xsl:otherwise>
> >         </xsl:case>
> >      </xsl:for>
> > </table>
> >


Hi,

I have nearly no experience with XSLT, nevertheless I would like to make a
suggestion for solving the problem. Please forgive me if this is totally
stupid ;-)


<table>
  <xsl:for-each select="group">
    <xsl:if test="position() mod 4 = 0">
      <tr>
        <xsl:apply-templates select="."/>
        <xsl:apply-templates select="following-sibling::*[position() = 1]"/>
        <xsl:apply-templates select="following-sibling::*[position() = 2]"/>
        <xsl:apply-templates select="following-sibling::*[position() = 3]"/>
      </tr>
    </xsl:if>
  </xsl:for>
</table>

<xsl:template match="element">
  <td>
     ...
  </td>
</xsl:template>


assuming:
<group>
  <element/>
  <element/>
  ...
  <element/>
</group>



regards,
Klaus Malorny

Mime
View raw message