|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Totals for conditional sums ?maybe?
> What I am trying to do is total the ORDD_TLNA for the base > years when > //AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumb > er)<1] and then later total ORDD_TLNA for the option years > when > //AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumb > er)>0]"> > > I have tried so many iterations I have forgotten them all but > I think the closest I have gotten is this: > > <xsl:variable name="TEST" > select="//AwardFullData/AwardItemizedLine[count(./periodLinePe > riodNumber)<1]"/> > <xsl:variable name="ADDME" > select="//AwardFullData/AwardItemizedLine/transactionAmount"/> > ... For some reason you've made this much more complicated than it is. Just select the nodes you want to total and apply the sum() function: sum(//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)<1]/ transactionAmount"/> I'm assuming here that transactionAmount does actually hold a numeric value. You haven't shown your source document, but there's a possible hint later in your question that suggests trasactionAmount might hold a currency sign. If that's the case then in 2.0 you can do sum(//AwardFullData/AwardItemizedLine[count(./periodLinePeriodNumber)<1]/ transactionAmount/ number(translate(.,'$',''))"/> > > <xsl:value-of select="sum($ADDME[$TEST])"/> There are several reasons this is wrong. Firstly, any expression of the form $ADDME[XXX] is going to select a subset of the nodes in $ADDME. These are AwardItemizedLine nodes, whereas you want to sum transactionAmount nodes. Secondly, $TEST is taken as true if //AwardFullData/AwardItemizedLine/transactionAmount selects any nodes, and as false if it doesn't; the value doesn't depend in any way on the AwardAtomizedLine node in question. > > > Not even sure if the above was correct I tried to strip the > formatting of the data which includes $ and , (I have no > control over the data source). At this point I think we need to see what the data looks like. A general comment: you're trying to do this by trial and error, which isn't a very good way of learning the language. The stylesheets you're working with aren't very well written, so learning from them isn't a good idea either. Take some time to read a good XSLT book. Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







