xsl-list
[Top] [All Lists]

[xsl] transform from flat to hierarchical

2006-11-27 01:16:24
Hi all,

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

<logs>
  <log>a</log>
  <log>sub b</log>
  <log>c</log>
  <log>sub d</log>
  <log>e</log>
  <log>f</log>
  <log>end of d</log>
  <log>g</log>
  <log>end of b</log>
  <log>h</log>
  <log>i</log>
<logs>

into a more structured content with nesting:

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

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).

Thanks,
kkt



--~------------------------------------------------------------------
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>