xsl-list
[Top] [All Lists]

Re: [xsl] How to convert a recursive function to a loop, using XSLT 2.0?

2019-05-10 06:26:34
On 10.05.2019 13:21, Costello, Roger L. costello(_at_)mitre(_dot_)org wrote:

My input file consists of a sequence (sourceSeq) of <Byte> elements representing a 
sequence of null-terminated strings. I want to create a function that returns a sequence of 
<String> elements. For example, with this sourceSeq:

<Byte>48</Byte>
<Byte>69</Byte>
<Byte>00</Byte>
<Byte>4A</Byte>
<Byte>69</Byte>
<Byte>6C</Byte>
<Byte>6C</Byte>
<Byte>00</Byte>

the function should return:

<String>Hi</String>
<String>Jill</String>

Seems like a job for
  <xsl:for-each-group select="Byte" group-ending-with="Byte[. = '00']">
    <String>...</String>
  </xsl:for-each-group>
where the ... processes current-group()[position() lt last()] to turn
bytes into characters/strings.
--~----------------------------------------------------------------
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>