Re: Union and descendants: count(.//name1|name2) ? Doesn't perform Union?

Subject: Re: Union and descendants: count(.//name1|name2) ? Doesn't perform Union?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jul 1999 17:53:56 -0700
At 99/07/12 19:13 -0400, Joshua Gough wrote:
>For example:
>
>count(.//entry|e) 
>
>Returns only the number of "entry" elements without adding the number of e
>matches to the result. 

Right ... probably because you don't have any 'e' children.

>Similarly,
>
>count(.//e|entry) 
>
>returns the number of e.

Right ... probably because you don't have any 'entry' children.

>However:
>
>count(./e|entry) 
>
>Works fine ... contains ... children.

As it should.

>But, I still figure the | operator should work. Can someone explain why
>this is not so?

Because the union operator separates the entire expression into
subexpressions and the context node for beginning the evaluation of each
subexpression is the current node.

You need (whitespace optional):   count( .//entry | .//e )

I hope this helps.

......... Ken


--
G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.             http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Publications:   Introduction to XSLT (3rd Edition) ISBN 1-894049-00-4
Next instructor-led training:   MS'99 1999-08-16  MT'99 1999-12-05/06


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread