[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Merge? Copy?
This is a grouping problem, and can be solved using Muenchian grouping - <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" /> <xsl:key name="by-customer" match="Customer" use="@id" /> <xsl:template match="/Customers"> <Customers> <xsl:for-each select="Customer[generate-id(.) = generate-id(key('by-customer',@id)[1])]"> <Customer id="{@id}"> <Name> <xsl:value-of select="Name" /> </Name> <Address> <xsl:value-of select="Address" /> </Address> <xsl:for-each select="key('by-customer',@id)"> <Sales> <date> <xsl:value-of select="Sales/date" /> </date> <amount> <xsl:value-of select="Sales/amount" /> </amount> </Sales> </xsl:for-each> </Customer> </xsl:for-each> </Customers> </xsl:template> </xsl:stylesheet> Regards, Mukul --- sbz sbz <sbz@xxxxxxxxxxxxxxxxx> wrote: > I have an XML file similiar to below. In this > example I need the Customer to appear only once, in > the real file it may be there once or 20 times. I > need the Sales data do be copied up from any > duplicate customer. > > I have thought about doing this using vbscript > maybe, but would prefer XSL to do it. I have looked > at merge but that requires loading 2 xml docs in. > I'd also prefer not have a duplicate xml file ... > the file will be over 600 megs so loading two would > be intensive. > > Is this even possible? > Any tips would be appreciated. Thank You. > > <Customers> > <Customer id="100"> > <Name></Name> > <Address></Address> > <Sales> > <date>August 1, 2004</date> > <amount>18</amount> > </Sales> > </Customer> > <Customer id="100"> > <Name></Name> > <Address></Address> > <Sales> > <date>August 10, 2004</date> > <amount>22</amount> > </Sales> > </Customer> > </Customers> > > Desired Result: > > <Customers> > <Customer id="100"> > <Name></Name> > <Address></Address> > <Sales> > <date>August 1, 2004</date> > <amount>18</amount> > </Sales> > <Sales> > <date>August 10, 2004</date> > <amount>22</amount> > </Sales> > </Customer> > </Customers> __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|