[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

Subject: Re: Avoiding the use of count when needing "at least one"
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 10 Jan 2001 00:53:12 +0000
least count
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.