xsl-list
[Top] [All Lists]

[xsl] Removing hierarchy

2009-10-01 07:41:59
I've got an input file like this:
<items>
  <item>
    <a>abc</a>
    <b>def</b>
    <item>
      <a>ghi</a>
      <b>jkl</b>
    </item>
    <item>
      <a>mno</a>
      <b>pqr</b>
      <item>
        <a>stu</a>
        <b>vwx</b>
      </item>
    </item>
  </item
</items

The items can be nested to any depth.

I want to convert this to:

<items>
  <item>
    <level>0</level>
    <a>abc</a>
    <b>def</b>
  </item
  <item>
    <level>1</level>
    <a>ghi</a>
    <b>jkl</b>
  </item>
  <item>
    <level>1</level>
    <a>mno</a>
    <b>pqr</b>
  </item
  <item>
    <level>2</level>
    <a>stu</a>
    <b>vwx</b>
  </item>
</items

In other words I want to remove the hierarchy of items and replace it with
a 'level' element.

What's the best way of doing this?

Many thanks - Rowan
    

--------------------------------------------------------------------
mail2web.com - Microsoft® Exchange solutions from a leading provider -
http://link.mail2web.com/Business/Exchange



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