xsl-list
[Top] [All Lists]

[xsl] xsl:for-each-group help needed !

2020-09-16 16:19:20
Hello all !

A slide is divided as blocks. Usually, there is one bloc per line, but sometimes, two or more blocks can be on one line, if their width sum is 100.

My input has non-grouped blocks, and I want my input group blocks per line.

Here is a sample input :

<blocks>
  <block id="i1">content</block>
  <block id="i2" width="33">content</block>
  <block id="i3" width="67">content</block>
  <block id="i4" width="50">content</block>
  <block id="i5" width="50">content</block>
  <block id="i6" width="25">content</block>
  <block id="i7" width="55">content</block>
  <block id="i8" width="20">content</block>
  <block id="i9">content</block>
</blocks>

Here is the expected output :

<blocks>
  <block id="i1">content</block>
  <block type="composite">
    <block id="i2" width="33">content</block>
    <block id="i3" width="67">content</block>
  </block>
  <block type="composite">
    <block id="i4" width="50">content</block>
    <block id="i5" width="50">content</block>
  </block>
  <block type="composite">
    <block id="i6" width="25">content</block>
    <block id="i7" width="55">content</block>
    <block id="i8" width="20">content</block>
  </block>
  <block id="i9">content</block>
</blocks>

I have no idea of which form of for-each-group I have to use...

Is a solution with two-pass where I first calculate cumulated width with an accumulator, followed a group-end-with="@cumulative-width eq 100" could be a correct solution ?

Best,
Christophe
--~----------------------------------------------------------------
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>