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

Re:Reformatting a flat XML doc into an XML hierarchy b

Subject: Re:Reformatting a flat XML doc into an XML hierarchy based on 2 keys
From: "Yang" <sfyang@xxxxxxxxxxxxx>
Date: Wed, 4 Apr 2001 09:51:53 +0800
xslt to flatten xml hierarchy
Hi, Vidhya,
Following may help for your problem.
Please refer to recent Jeni's  reply for multi-level group
http://sources.redhat.com/ml/xsl-list/2001-04/msg00120.html

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:key name="foo"   match="row"  use="year"/>
<xsl:key name="bar"     match="row" use="concat(year,' ',acct)"/>

 <xsl:template match="/">
   <data>
     <xsl:for-each select="data/row[generate-id(.)
=generate-id(key('foo',year)[1])]">
 <xsl:variable name="year" select="year"/>
 <ActivityDate year="{$year}">
  <xsl:for-each select="key('foo',year)[generate-id(.)
=generate-id(key('bar',concat(year,' ',acct))[1])]">
 <xsl:variable name="acct" select="acct"/>
   <Acct id="{$acct}">
    <xsl:for-each select="key('bar',concat(year,' ',acct))">
      <Name>
       <xsl:value-of select="acctname"/>
      </Name>
     </xsl:for-each>
     </Acct>
   </xsl:for-each>
  </ActivityDate>
   </xsl:for-each>
   </data>
 </xsl:template>
</xsl:stylesheet>

hope it will help

sun-fu yang

sfynag@xxxxxxxxxxxxx



 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.