[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: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 8 Mar 2004 09:55:37 +0000
xml three columns
Hi Dionisio,

> y have the bellow xml file and i want to put the data, the
> paginas_titulo node in 3 columns:
[snip]
> 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.

The first task is to select one sn_masterinformacion element to
represent each row, so that you generate the correct number of rows.
The first sn_masterinformacion elements in each row are numbered 1, 4,
7 etc. You can select them by looking at the remainder after dividing
by 3, using:

  sn_masterinformacion[position() mod 3 = 1]

These sn_masterinformacion elements give the content for the first
cell in each row. The next two sn_masterinformacion elements give the
content for the following cells, if there are any. Since you just want
the <td> to be empty in this case, the easiest thing is to create the
cells and use the content from the next two following sibling
sn_masterinformacion elements in them.

Something like:

  <xsl:for-each select="sn_masterinformacion[position() mod 3 = 1]">
    <tr>
      <td><xsl:apply-templates select="." /></td>
      <td>
        <xsl:apply-templates
          select="following-sibling::sn_masterinformacion[1]" />
      </td>
      <td>
        <xsl:apply-templates
          select="following-sibling::sn_masterinformacion[2]" />
      </td>
    </tr>
  </xsl:for-each>

with a template for the sn_masterinformacion element just giving the
value of the appropriate paginas_titulo element it contains:

<xsl:template match="sn_masterinformacion">
  <xsl:value-of select="paginas/sn_paginas/paginas_titulo" />
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.