Subject: Re: [xsl] Avoiding the use of count when needing "at least one" From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 10 Jan 2001 00:53:12 +0000 |
Hi Anchal, > I would like to print out a certain string if there is at least one > EmployeeName element that has a Manager type and a different string > if there isn't even one EmployeeName element that has a Manager > Type. > [snip] > <xsl:when test="count(EmployeeName[@Type='Manager']) != 0"> [snip] The test that you're using there is exactly equivalent to: EmployeeName[@Type='Manager'] The above XPath returns all the EmployeeName elements that have a @Type attribute with a value of 'Manager'. When this node set is evaluated as a boolean (e.g. in a 'test' attribute or in a predicate) then it's counted as true if there any nodes in it, false if not. Most good XSLT processors will perform some kind of optimisation that stops and returns true after the first matching node is found. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Avoiding the use of count whe, Anchal Jain | Thread | Re: [xsl] copying attributes, Jeni Tennison |
RE: [xsl] xsl:script: functions wri, Nacho | Date | Re: [xsl] variables/parameters in m, Jeni Tennison |
Month |