[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Avoiding the use of count when needing "at least o
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|