This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: counting question
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Jo Bourne <venus at va dot com dot au>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 9 Jan 2002 07:30:59 +0000
- Subject: Re: [xsl] counting question
- Organization: Jeni Tennison Consulting Ltd
- References: <a05100313b86199f46823@[203.15.106.241]>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Jo,
> I am wanting to count all the child elements of a particular element
> and treat them one way if there is only one child and another if
> there are multiple. Is the best way to do this to test if the child
> is both first and last or is there some other more sensible method?
You can do it using the count() function:
count(*) = 1
returns true if the context node has exactly one child element.
Another method is to test whether there is a second child element:
not(*[2])
returns true if there isn't a second child element (i.e. if there are
0 or 1 child elements).
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list