RE: [xsl] RE: Totals for conditional sums ?maybe?

Subject: RE: [xsl] RE: Totals for conditional sums ?maybe?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 6 Dec 2005 22:01:19 -0000
> This statement strips all non-numeric characters (haven't made it to
> reformating back to $###,###.## yet):
> 
> <xsl:value-of
> select="(translate(//AwardFullData/AwardItemizedLine/transacti
> onAmount,t
> ranslate(//AwardFullData/AwardItemizedLine/transactionAmount,'
> 0123456789
> ', ''), ''))"/>
> 
> Result when applied to data: 180400

That's with a 1.0 processor (using a node-set where a string is expected
takes the string value of the first node and ignores the others). With a 2.0
processor (in 2.0 mode) this will give you an error: if you want the first
item only, you have to say so; if you want to convert all the nodes, you use
a "for" expression.
> 
> 
> This statement is supposed to sum transactionAmount where count of
> periodLinePeriodNumber <1
> 
> <xsl:value-of select="
    sum(translate(....
> 
> Result when applied to data: Can not convert #STRING to a NodeList!
> 

The sum() function in 1.0 expects a node-set, the translate function returns
a string, and (as the Xalan message almost says) you cannot convert a string
to a node-set.
> 
> Any suggestions?
> 

Use one of the several approaches given in previous responses.

Michael Kay
http://www.saxonica.com/

Current Thread