Hi Folks,
I have an XML document containing a long list of Byte elements, e.g.,
<Bytes>
<Byte hexAddress="0">4D</Byte>
<Byte hexAddress="1">5A</Byte>
<Byte hexAddress="2">90</Byte>
<Byte hexAddress="3">00</Byte>
<Byte hexAddress="4">03</Byte>
<Byte hexAddress="5">00</Byte>
<Byte hexAddress="6">00</Byte>
<Byte hexAddress="7">00</Byte>
<Byte hexAddress="8">04</Byte>
<Byte hexAddress="9">00</Byte>
<Byte hexAddress="A">00</Byte>
<Byte hexAddress="B">00</Byte>
<Byte hexAddress="C">FF</Byte>
<Byte hexAddress="D">FF</Byte>
...
</Bytes>
I have a string of hex values, e.g.,
04000000FF
You can see that the string is contained within this series of Byte elements:
<Byte hexAddress="8">04</Byte>
<Byte hexAddress="9">00</Byte>
<Byte hexAddress="A">00</Byte>
<Byte hexAddress="B">00</Byte>
<Byte hexAddress="C">FF</Byte>
I want to find the number of <Byte> elements that occur prior to the series of
Byte elements.
I figured one approach is to convert all the Byte text node values into a
string and then perform string manipulations:
string-length(substring-before(string-join(/Bytes/Byte/text(), ''),
'04000000FF')) idiv 2
Note: I divided by two because each Byte has 2 digits.
That seems to work, but I suspect it is horribly inefficient because it creates
a string containing all the Byte text node values and there may be tens or
hundreds of thousands of Byte elements.
What is an efficient way to solve this problem?
/Roger
--~----------------------------------------------------------------
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
--~--