[xsl] transform from flat to hierarchical

Subject: [xsl] transform from flat to hierarchical
From: "Ken Tam" <kentam@xxxxxxxxxxxxxxx>
Date: Mon, 27 Nov 2006 00:15:41 -0800
Hi all,

I need to transform from flat and somewhat unstructured XML to a more
structual form. Here is a sample:

  <log>sub b</log>
  <log>sub d</log>
  <log>end of d</log>
  <log>end of b</log>

into a more structured content with nesting:

  <log name="a">
    <log name="b">
      <log name="c">
        <log name="d">
          <log name="e"/>
          <log name="f"/>
      <log name="g"/>
  <log name="h"/>
  <log name="i"/>

Is this doable by using XSLT/XPATH?. If yes, please include some sample XSLT
code. I've looked at some examples of "flat to hierarchical" transformations
but they are dealt with nestings that are determined by a single node (i.e.
with a "level" attribute) instead of begin-end node pair (as in the "sub
<node>", "end of <node>" pair from above).


Current Thread