Subject: RE: [xsl] firing on more than one match From: "Passin, Tom" <tpassin@xxxxxxxxxxxx> Date: Fri, 17 Oct 2003 13:05:01 -0400 |
[Ronald Kent Gibson] > I have something like this, ie there are more is more than > one node that is > named ruledef, and I want my condition to fire when any of > these things are > equal to the condition. > > <xsl:when test="/ruledef[1]/@pageeject = 'yes'"> > > </xsl:when> > > > Seems like a loop would be good here, but no loops in xslt. > > I don't thinkr recursion will help, either. So can anyone > kindly give me > some suggestions, thanks and enjoy the weekend. > Basically, just select the node set that you want. Something like this is simple (I am assuming that the ruledef elements are immediate children of a "root" element) - <xsl:template match="/root"> <results> <xsl:apply-templates select='ruledef[@pageeject="yes"]' mode='eject'/> </results> </xsl:template> <xsl:template match='ruledef' mode='eject'> ---Fire rule here --- </xsl:template> Your example shows one of the really nice things about xslt, but one that can be surprising to newcomers. The select expression applies the test to each candidate node, and returns only the set of nodes that pass the test. So you do not need to "loop" or do anything else - the system just automatically does what you want (you _could_ write a "loop" in several ways, including using xsl:for-each, but there is no point in doing so in this case). BTW, I only used a "mode" attribute in case you might want to have other templates for ruledef nodes besides the pageeject template. If you do not, you could omit the "mode" attributes in both places. Cheers, Tom P XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] firing on more than one m, Benjamin Farrow | Thread | RE: [xsl] consolidating footnotes/n, Whitney, Dan (CanWes |
RE: [xsl] firing on more than one m, Lars Huttar | Date | Re: [xsl] firing on more than one m, Mukul Gandhi |
Month |