[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Removing hierarchy

Subject: Removing hierarchy
From: "rowan@xxxxxxxxxxxxxxxxxxxxx" <rowan@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 1 Oct 2009 07:41:24 -0400
 Removing hierarchy
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.