Re: [xsl] problem with XPath count()

Subject: Re: [xsl] problem with XPath count()
From: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 1 Nov 2023 14:58:58 -0000
Indeed.

Or, to be more literal and less XPath-idiomatic,

empty(preceding-sibling::*)

Thanks Mike! For this contribution and every other time you've rescued us from
ourselves.

Cheers, Wendell

From: Michael Kay mike@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Wednesday, November 1, 2023 4:49 AM
To: xsl-list <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: [xsl] problem with XPath count()


I want to count, for each element, the number of preceding <text>
elements that satisfy one or both of the following two conditions: 1)
the element is the first of the list or 2) its string value begins with
"x". Here is an example, with the expected number of the count after the
element:

Firstly, I suspect you want the preceding-sibling axis rather than the
preceding axis.

The position() function returns the position of a node within the sequence of
nodes being processed, not its position within an XML tree. If you use it
within a predicate, it's the position of the item being tested within the
sequence of things being tested, which in your case is the sequence of
preceding text elements, in reverse document order.

To test whether a node is the first element child of its parent, use

not(preceding-siblling::*)

Michael Kay
Saxonica

XSL-List info and archive<http://www.mulberrytech.com/xsl/xsl-list>
EasyUnsubscribe<http://lists.mulberrytech.com/unsub/xsl-list/3302254> (by
email<>)

Current Thread