[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: From one xml put the data into 3 columns. Please h
Hi, > I have one great problem, for me. > During 2 weeks i have one great problem and i don't know how > to solve it. > > > y have the bellow xml file and i want to put the data, the > paginas_titulo > node in 3 columns: > <tr><td>paginas_titulo 1</td><td>paginas_titulo > 2</td><td>paginas_titulo > 3</td></tr> > <tr><td>paginas_titulo 4</td><td>paginas_titulo > 5</td><td>paginas_titulo > 6</td></tr> > > ...... > > if there are 5 nodes (paginas_titulo nodes) apears one row > with 3 columns > with data and other row with 2 columns with data and the other without > data. <xsl:template match="sn_servicioproyecto"> <xsl:variable name="cols" select="3"/> <table> <tbody> <xsl:for-each select="informacion/sn_masterinformacion[position() mod $cols = 1]"> <tr> <xsl:for-each select=". | following-sibling::sn_masterinformacion[position() <= 2]"> <td> <xsl:value-of select="paginas/sn_paginas/paginas_titulo"/> </td> </xsl:for-each> <!-- filler --> <xsl:for-each select="(document('')//node())[position() < ($cols - count(current()/following-sibling::sn_masterinformacion))]"> <td/> </xsl:for-each> </tr> </xsl:for-each> </tbody> </table> </xsl:template> The filler bit above isn't really that efficient, e.g. <xsl:if test="not(following-sibling::sn_masterinformacion[1])"> <td/> <xsl:if test="not(following-sibling::sn_masterinformacion[2])"> <td/> </xsl:if> </xsl:if> is faster and more readable. Cheers, Jarno - The Cure: To Wish Impossible Things XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|