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

dynamic node sets

Subject: dynamic node sets
From: "FRIEDLAND, STEPHEN R" <STEPHEN_R_FRIEDLAND@xxxxxxxxx>
Date: Wed, 27 Mar 2002 11:10:51 -0500
stephen friedland
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. 

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

<xsl:template name="getSum">
	<xsl:param name="nodelist"/>
	<xsl:value-of select="sum($nodelist)"/>
</xsl:template>
		
myData.xml ===========================================
<?xml version="1.0" ?>

<TradeData date='2002-03-18'>
	<ColumnInfo>
		<column colname="TradeType" align="left"/>
		<column colname="TradeId" align="center"/>
		<column colname="TradeValue" align="right" hasTotal="true"/>
	</ColumnInfo>

	<Trades>
		<TradeEntry>
			<TradeType>TypeA</TradeType>
			<TradeId>12345</TradeId>
			<TradeValue>100.00</TradeValue>
		</TradeEntry>
		<TradeEntry>
			<TradeType>TypeB</TradeType>
			<TradeId>45678</TradeId>
			<TradeValue>500.00</TradeValue>
		</TradeEntry>
		<TradeEntry>
			<TradeType>TypeC</TradeType>
			<TradeId>56789</TradeId>
			<TradeValue>350.00</TradeValue>
		</TradeEntry>
	</Trades>
</TradeData>
==========================================================

Thanks,
- Steve

- Stephen Friedland
- stephen_r_friedland@xxxxxxxxx

 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.