[quoted text, click to view] "Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:%232IbWYcXEHA.3476@tk2msftngp13.phx.gbl...
> Alfred Taylor wrote:
>
> > I essentially need a countif() function for xsl. Something to where I
could
> > do countif(node-set, condition). Rather than try to get too extreme, i
> > decided to just write one for my countif() with the condition hardcoded.
> > (this was also my first venture into creating "functions")
>
> Well, are you sure you can't do that with count() function?
> E.g. count(//employee[@wage>60000])
I guess countif() was a bad example to use. It's essentially a
countifAndSum() function. ;)
[quoted text, click to view] >
> The problem usually is with sum() function when one needs to get sum of
> calculated values. Then the simplest (but not the most effective)
> solution is using temporary tree of calculated values and then coverting
> it to nodeset using xxx:node-set function and summing. Other solution is
> recursive template just like yours, but instead of passing index,
> usually tail nodeset is passed (nodeset with no first node):
> <xsl:with-param name="nodes" select="$nodes[position()>1]"/>
> You may want to look at FXSL library where this ideas were developed
> much further.
Ahh crap. Brings back bad memories of the days they taught me functional
languages. Man, looks like i'll have to get myself back into that mindset.
Thanks for reminding me on the different programming paradigms.
As for using xxx:node-set(), i'm still have a terrible time getting it to
work with the .NET transform. something as simple as this:
-- SNIP
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:template match="/">
<xsl:call-template name="testMe">
<xsl:with-param name="param1" select="." />
</xsl:call-template>
</xsl:template>
<xsl:template name="testMe">
<xsl:param name="param1" />
<xsl:value-of select="msxsl:node-set($param1)/Example/Element/@Value" />
</xsl:template>
</xsl:stylesheet>
-- END
I've read numerous other posts with people being able to use it
successfully, but i must be missing something here.
-A
[quoted text, click to view] >
> > My problem is that i get an error when i try to index into the node-set
like
> > this $node-set[$index].
>
> Which error? Try $node-set[position()=$index]
>
> --
> Oleg Tkachenko [XML MVP]
>
http://blog.tkachenko.com