Subject: Re: [xsl] problem with XPath count() From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 1 Nov 2023 08:48:44 -0000 |
> 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem with XPath count(, ajbufort@xxxxxxxxxxx | Thread | Re: [xsl] problem with XPath count(, Piez, Wendell A. (Fe |
Re: [xsl] problem with XPath count(, ajbufort@xxxxxxxxxxx | Date | [xsl] XSL-List Guidelines, B Tommie Usdin btusd |
Month |