XSLT creating a table with varying amount of columns

Posted by H4mm3rHead on Stack Overflow See other posts from Stack Overflow or by H4mm3rHead
Published on 2010-04-20T16:43:00Z Indexed on 2010/04/20 17:43 UTC
Read the original article Hit count: 291

Filed under:
|
|

Hi, I have a RSS feed i need to display in a table (its clothes from a webshop system). The images in the RSS vary in width and height and I want to make a table that shows them all. First off i would be happy just to show all of the items in 3 columns, but further down the road i need to be able to specify through a parameter the amount of columns in my table. I run into a problem showing the tr tag, and making it right, this is my Code so far:

 <xsl:template match="item">
    <xsl:choose>      
      <xsl:when test="position() mod 3 = 0 or position()=1">
        <tr>
          <td>
            <xsl:value-of select="title"/>
          </td>
        </tr>
        </xsl:when>
      <xsl:otherwise>
        <td>
          <xsl:value-of select="title"/>
        </td>
      </xsl:otherwise>
    </xsl:choose>    
  </xsl:template> 

In RSS all "item" tags are on the same level in the xml, and thus far i need only the title shows. Thr problem seems to be that i need to specify the start tag as well as the end tag of the tr element, and cant get all 3 elements into it, anyone know how to do this?

© Stack Overflow or respective owner

Related posts about xslt

Related posts about ASP.NET