It depends entirely on the XPath processor you are using.
For Saxon, I wouldn't expect to see a measurable difference. Unless there
happen to be 100,000 B elements before the A on which you are positioned, in
which case count(../A) might take rather longer.
Michael Kay
Saxonica
mike(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893
On 4 Nov 2014, at 13:57, Costello, Roger L. costello(_at_)mitre(_dot_)org
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
Hi Folks,
I am positioned in the XML tree at the first <A> element, within a <parent>
element.
Requirement: There must be only one <A> element within <parent>.
Here are two XPath expressions to check that there is only one <A> element:
count(../A) eq 1
or
not(following-sibling::A)
Which XPath expression evaluates faster?
/Roger
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--