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

Subject: Re: [xsl] Find the number of elements that are prior to the seriesof elements that match a string?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Mar 2019 19:55:07 -0000
On 12.03.2019 20:21, Eliot Kimber ekimber@xxxxxxxxxxxx wrote:
I was thinking of doing something with looking up the individual byte() elements using key() on the string values but I couldn't think of an elegant way to split the input string into two-character chunks.

Interesting, why do you need the string splitting for the key? Wouldn't


<xsl:param name="input" as="xs:string">04000000FF</xsl:param>
<xsl:variable name="len" as="xs:integer" select="string-length($input) idiv 2"/>


<xsl:key name="window" match="Bytes/Byte" use="string-join((., following-sibling::Byte[position() lt $len]))"/>

<xsl:template match="/">
<xsl:value-of select="count(key('window', $input)[1]/preceding-sibling::Byte)"/>
</xsl:template>


do?

Current Thread