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

flat structure to hierarchy

Subject: flat structure to hierarchy
From: lui.alex@xxxxxxxxxx
Date: Wed, 7 Aug 2002 12:13:31 +0800
flat structure
I need to transform a flat structure XML to a more structured one with
groupby.

Input:
<rows>
  <row>
    <tag1>a1</tag1>
    <tag2>b1</tag2>
    <tag3>c1</tag3>
    <tag4>d1</tag4>
  </row>
  <row>
    <tag1>a2</tag1>
    <tag2>b2</tag2>
    <tag3>c2</tag3>
    <tag4>d2</tag4>
  </row>
  <row>
    <tag1>a2</tag1>
    <tag2>b2</tag2>
    <tag3>c3</tag3>
    <tag4>d3</tag4>
  </row>
  <row>
    <tag1>a3</tag1>
    <tag2>b3</tag2>
    <tag3>c4</tag3>
    <tag4>d4</tag4>
  </row>
</rows>

Output:
<records>
  <record level="0">
    <tag1>a1</tag1>
    <tag2>b1</tag2>
    <record level="1">
      <tag3>c1</tag3>
      <tag4>d1</tag4>
    </record
  </record>
  <record level="0">
    <tag1>a2</tag1>
    <tag2>b2</tag2>
    <record level="1">
      <tag3>c2</tag3>
      <tag4>d2</tag4>
    </record>
    <record level="1">
      <tag3>c3</tag3>
      <tag4>d3</tag4>
    </record>
  </record>
  <record level="0">
    <tag1>a3</tag1>
    <tag2>b3</tag2>
    <record level="1">
      <tag3>c4</tag3>
      <tag4>d4</tag4>
    </record
  </record>
</rows>

You can assume that rows are sorted and related rows are grouped together.
It seems that some sort of lookaheads are needed. How can this be done
efficiently in XSL?

Thanks in advance.
Alex


CONFIDENTIALITY: This communication and any attachment(s) is intended solely
for the person or organisation to which it is addressed and it may be
confidential. If you are not the intended recipient, employee or agent
responsible for delivering the message to the intended recipient you must
not copy, disclose, distribute or take any action in reliance on it. If you
have received this communication in error, please notify the sender
immediately and destroy the original.  If this communication has been
received by email please reply and highlight the error to the sender and
delete the original.  Thank you.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.