xsl-list
[Top] [All Lists]

Re: Is there another way to do this?

2004-03-03 03:47:48

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



<Prev in Thread] Current Thread [Next in Thread>