xsl-list
[Top] [All Lists]

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

2019-03-12 15:31:09
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(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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
--~----------------------------------------------------------------
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
--~--
<Prev in Thread] Current Thread [Next in Thread>