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

Re: dynamic node sets

Subject: Re: dynamic node sets
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Mar 2002 18:19:17 +0000
columninfo xsl for each
Hi Stephen,

> Hi, I'm trying to get the sum of named columns but am running into
> trouble. I'd like to get the total for columns having a hasTotal
> attribute. The xsl fragment I'm trying to use is below. The problem
> is that the nodelist param is illegal (select="//$curname"). I can't
> seem to create a nodelist without hardcoding the element name
> (select="//TradeType"), but I don't know in advance which elements
> will be present and which ones have totals.

Try selecting all the elements and then filtering them to select only
those of the specified name:

  //*[name() = $curname]

Personally, I'd do the xsl:for-each over the column children of the
ColumnInfo element (rather than the first TradeEntry), as that makes
it easier to work out whether you need to add a total or not for it.
I'd also step down to the relevant values rather than looking through
all the elements in the document, as doing so is more efficient. So
I'd use:

  <xsl:for-each select="ColumnInfo/column">
    <xsl:if test="@hasTotal">
      <xsl:variable name="colname" select="@colname" />
      <xsl:variable name="entries"
        select="/TradeData/Trades/TradeEntry/*[name() = $colname]" />
      <td>
        <xsl:call-template name="getSum">
          <xsl:with-param name="nodelist" select="$entries" />
        </xsl:call-template>
      </td>
    </xsl:if>
  </xsl:for-each>

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.