[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

Subject: RE: From one xml put the data into 3 columns. Please help me
From: Jarno.Elovirta@xxxxxxxxx
Date: Mon, 8 Mar 2004 11:29:26 +0200
xml data into table
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() &lt;= 2]">
              <td>
                <xsl:value-of select="paginas/sn_paginas/paginas_titulo"/>
              </td>
            </xsl:for-each>
            <!-- filler -->
            <xsl:for-each select="(document('')//node())[position() &lt; ($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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.