Re: [xsl] Find the number of elements that are prior to the series of elements that match a string?

Subject: Re: [xsl] Find the number of elements that are prior to the series of elements that match a string?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Mar 2019 20:31:04 -0000
In performance terms, of course, a solution using keys incurs a one-time cost
to build indexes, which is amortized over a number of searches; so the
performance benefits depend on whether the search is done once, or
repeatedly.

If there are "hundreds of thousands" of Byte elements, the space used by the
index can become a significant factor.

Also, a solution using keys will almost inevitably process the whole input
sequence. Other solutions are likely to stop reading the input sequence when
the first match is found.

Michael Kay
Saxonica

> On 12 Mar 2019, at 20:20, Dimitre Novatchev dnovatchev@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Here is an XSLT 2.0 solution using keys. In its current form it
> returns the wanted offset (length) as a hexadecimal number. To convert
> this to a decimal number, have a look at the archives where AFAIR
> there is such code -- could be even posted by me ... This conversion
> to decimal can certainly be written elegantly as fold-left() in
> XSLT/XPath 3

Current Thread