This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Trying to use the SUM function on an attribute
- To: mhkay at iclway dot co dot uk, desimonp at iname dot com
- Subject: RE: [xsl] Trying to use the SUM function on an attribute
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- Date: Fri, 26 Jan 2001 22:34:44 -0800 (PST)
- Cc: xsl-list at lists dot mulberrytech dot com
- Reply-To: xsl-list at lists dot mulberrytech dot com
> var totalVal = xmlToSum.selectSingleNode("sum(//@attr1)")
This is not going to work -- the XPath expression argument in
selectSingleNode() must evaluate to a node(-set). And what will be
returned in this case will be a scalar (a string containing a number or
NaN).
One way to obtain a scalar value from an XPath expression is when a
client uses the transformNode() method that applies to the source a
generic template, which outputs (xsl:value-of) the value of an XPath
expression passed as a parameter.
Dimitre Novatchev.
> > I would like to do the following in JScript:
> >
> > var totalVal = xmlToSum.selectSingleNode("sum(///@attr1")
> >
> > But when I try to open this page, I get an error "Expected
> > Identifier".
> >
> > What would be the proper syntax.
> >
>
> var totalVal = xmlToSum.selectSingleNode("sum(//@attr1)")
>
> Mike Kay
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list