The reason you're getting hung up is actually logical.  What
if there are an odd number of items?  Your logic will produce
no </TR> which IS invalid...

What you need to do is output on every OTHER item and then
output the next one if it's there.  That way you always have
the ending /TR and you generate an empty <TD></TD> block...

Something like

<TABLE>
  <xsl:for-each select="ITEM">
    <xsl:variable name="pos" select="position()"/>
    <xsl:if test="$pos mod 2"/>
      <TR>
         <TD>
           <xsl:value-of select"."/>
         </TD>
         <TD>
            <xsl:if test="../ITEM[$pos + 1]">
               <xsl:value-of select="../ITEM[$pos + 1]"/>
            </xsl:if>
         </TD>
      </TR>
    </xsl:if>
  </xsl:for-each>
</TABLE>

You could also make the last one a colspan of 2 if you'd
rather...


> -----Original Message-----
> From: Andre Cusson [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, March 31, 2002 11:20 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [OT] uneven tags inside XSLT conditionals
>
>
> sorry, also drop the <tr></tr> in one of the two (when/otherwise)
> ac
>
>
>
> -----Message d'origine-----
> De : Andre Cusson [mailto:[EMAIL PROTECTED]]
> Envoyé : 31 mars, 2002 13:16
> À : [EMAIL PROTECTED]
> Objet : RE: [OT] uneven tags inside XSLT conditionals
>
>
> How about adding a </tr> at the end of the when clause and adding
> a <tr> at
> the start of the otherwise clause.
> ac
>
>
>
> -----Message d'origine-----
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Envoyé : 31 mars, 2002 11:16
> À : [EMAIL PROTECTED]
> Objet : [OT] uneven tags inside XSLT conditionals
>
>
> Hey,
>
>   I've done some googling and I cant find the answer to this.
>
>   I basically want to do:
>
> <xsl:choose>
>       <xsl:when test="position() mod 2">
>               <tr>
>                       <td>
>                               <xsl:value-of select="@name"/>
>                       </td>
>       </xsl:when>
>       <xsl:otherwise>
>                       <td>
>                               <xsl:value-of select="@name"/>
>                       </td>
>               </tr>
>       </xsl:otherwise>
> </xsl:choose>
>
>
> So basically there will be two columns of @name printed.  The problem with
> this setup is that the <tr> and </td> make the whole thing
> malformed/invalid due to the broken nesting.  Is there a way to get around
> this, or maybe a more "proper" way of achieving the same end?
>
> -Tom
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail: <[EMAIL PROTECTED]>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to