Re: [xsl] Need XPath 2.0 expression which returns a non-empty paragraph element that is preceded by a long uninterrupted series of empty paragraph elements

Subject: Re: [xsl] Need XPath 2.0 expression which returns a non-empty paragraph element that is preceded by a long uninterrupted series of empty paragraph elements
From: "Peter Flynn peter@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 25 Nov 2019 20:07:50 -0000
On 25/11/2019 19:39, Costello, Roger L. costello@xxxxxxxxx wrote:
[snip]

That is, my XPath query does not account for the requirement that the long series of paragraph elements be uninterrupted. How to write
an XPath 2.0 query for this?
preceding-sibling() count *any* preceding sibling, not contiguous preceding siblings

I think you need to locate the closest preceding element that is *not* empty of text, and the count the elements between that and your context element, eg:

   count(preceding-sibling::p[.!='&#160;'][1]
     /following-sibling::p[.='&#160;'])

That should return 24 for your first example and 9 for the second.


P


Current Thread