This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
flat structure to hierarchy
- From: lui dot alex at hit dot com dot hk
- To: XSL-List at lists dot mulberrytech dot com
- Date: Wed, 7 Aug 2002 12:13:31 +0800
- Subject: [xsl] flat structure to hierarchy
- Reply-to: xsl-list at lists dot mulberrytech dot com
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