[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to view data in tabuler view

Subject: Re: how to view data in tabuler view
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 12:52:39 +0000
view tbody
Hi Mohamed,

> the above data must view in tabuler form, which caption is the
> titles or table header , and the values are table body.
>
> my first question is how to put all captions as titles which the
> caption repeat every row and i want to get it once only,and put each
> related data under its title

When you create the table header, only iterate over the captions in
the *first* row of your source; when you create the table body,
iterate over *all* the rows and only look at the amount under each
item:

<xsl:template match="document">
  <table>
    <thead>
      <tr>
        <xsl:for-each select="row[1]/item">
          <th><xsl:value-of select="caption" /></th>
        </xsl:for-each>
      </tr>
    </thead>
    <tbody>
      <xsl:for-each select="row">
        <tr>
          <xsl:for-each select="item">
            <td><xsl:value-of select="amount" /></td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </tbody>
  </table>
</xsl:template>

> second how to put currency value beside price without currency
> caption.

Only iterate over those items whose caption is not 'currency'; when
you're processing an item whose caption is 'Unit Price' then include
the <amount> for the <item> in the same <row> whose caption is
'currency':

<xsl:template match="document">
  <table>
    <thead>
      <tr>
        <xsl:for-each select="row[1]/item[caption != 'currency']">
          <th><xsl:value-of select="caption" /></th>
        </xsl:for-each>
      </tr>
    </thead>
    <tbody>
      <xsl:for-each select="row">
        <tr>
          <xsl:for-each select="item[caption != 'currency']">
            <td>
              <xsl:value-of select="amount" />
              <xsl:if test="caption = 'Unit Price'">
                <xsl:value-of
                  select="../item[caption = 'currency']/amount" />
              </xsl:if>
            </td>
          </xsl:for-each>
        </tr>
      </xsl:for-each>
    </tbody>
  </table>
</xsl:template>

It's probably actually not a good idea to use the value of the
<caption> elements to work out what each item contains; if you had a
'type' attribute or something that was less likely to change then that
would be better, but at the moment the caption is the only thing that
you can really use.

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.