Subject: Re: [xsl] dynamic node sets From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 27 Mar 2002 18:19:17 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] dynamic node sets, FRIEDLAND, STEPHEN R | Thread | [xsl] Comparing two large styleshee, Andrew Welch |
Re: [xsl] sequence numbering., Jeni Tennison | Date | [xsl] windows-like table sorter, Robert Sösemann |
Month |