Subject: Re: [xsl] Is there another way to do this? From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 3 Mar 2004 10:47:48 GMT |
> This works but I'm just wondering is there a simpler method for doing this? Not much, I would probably pass the node rather than the node number, and recurse by passing following-sibling::*[1] rather than adding 1, this might save the system indexing into the list repeatedly (although passing a node rather than an integer may also have costs, implementation details...) and is more "the xslt way", however what you have is fine. In Xslt2 drafts this is much simpler as you can just do <xsl:value-of select="format-number(sum(for $i in item return $i/units * $i/unit.price), '#0.00')"/> The need to introduce a variable here, and the fact that for does not change the current node, so you have to do $i/item is a bit ugly, I still hope to see a more xpath like iterator in xpath2 which would be something like <xsl:value-of select="format-number(sum(item ?? (units * unit.price), '#0.00')"/> where ?? is some operator like / but allowing values. However even with the for expression that wandered into xpath by mistake from sql, it is still a lot simpler than xslt1. David -- http://www.dcarlisle.demon.co.uk/matthew ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Is there another way to do th, Tim Lumley | Thread | RE: [xsl] Is there another way to d, Michael Kay |
RE: [xsl] Is there another way to d, Jarno . Elovirta | Date | [xsl] Iterative variation of attrib, i92agcad |
Month |