xsl-list
[Top] [All Lists]

[xsl] [XSLT2] Grouping by matching properly nested pairs

2006-11-15 16:32:36
(A grouping question - again...)

The task is to create a nested grouping from a flat list of elements
based on matching "properly nested" <start/> and corresponding <end />
elements. Nesting depth is arbitrary.

Source XML:

<root>
    <a />
    <start />
    <b />
    <start />
    <c />
    <end />
    <d />
    <start />
    <start />
    <e />
    <end />
    <f />
    <end />
    <g />
    <end />
</root>

or, for better legibility indented with the intended result in mind:

<root>
    <a />
    <start />
      <b />
      <start />
        <c />
      <end />
      <d />
      <start />
        <start />
          <e />
        <end />
        <f />
      <end />
      <g />
    <end />
</root>


The result should be:

<root>
    <a />
    <group>
      <b />
      <group>
        <c />
      </group>
      <d />
      <group>
        <group>
          <e />
        </group>
        <f />
      </group>
      <g />
    </group>
</root>

How is this best tackled? group-starting-with="" doesn't seem to be the
way to go, because it will create non-nested groups on each <start />,
but the groups need to be nested.

-Christian


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>