Subject: RE: [xsl] A more complicated Muenchian Method exercise From: Américo Albuquerque <melinor@xxxxxxx> Date: Mon, 21 Jul 2003 16:29:24 +0100 |
Hi > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Greg Johnson > Sent: Monday, July 21, 2003 2:30 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] A more complicated Muenchian Method exercise > > > In this last week and a half, I have been on a serious > learning curve, and this list has helped me a lot. Thanks. > Now I need some more. :) > > I have the following (abbreviated) XML Structure > > <report> > > <header> > <date></date> > <sender> > <sen_id></sen_id> > <recipient> > <rec_id></rec_id> > <detail></detail> > <detail></detail> > </recipient> > </sender> > </header> > > <header> > <date></date> > <sender> > <sen_id></sen_id> > <recipient> > <rec_id></rec_id> > <detail></detail> > <detail></detail> > <detail></detail> > </recipient> > </sender> > </header> > > ... > > </report> > > > I would like to make a report based on the above XML that has > a primary grouping by "date", which is no problem. What I'm > not sure about is how to do a second grouping on the UNIONED > SET of senders and recipients. That is, I have a set called > "Trading Partner", of which "sender" and "recipients" are > members. That way I can then produce an output that groups > on TP's, and then I could output the documents that were > received, and then sent for a particular "Trading Partner". Like the > following: > > REPORT > DATE1 > TRADING PARTNER: "name1" > DOCUMENTS SENT > DOCUMENTS REC'D > TRADING PARTNER: "name2" > DOCUMENTS SENT > DOCUMENTS REC'D > DATE2 ... > So, your second group will be on the pair(sen_id, rec_id). You can do that using concat instead of union '|' Something like: <xsl:key name="key2_name" match="header" use="concat(date,':',sender/sen_id,' ',sender/recipient/rec_id)"/> According to you output you want to display unique pairs so you can count how many docs has been sent. You do this applying the second group in the same way you applyied the first: <xsl:apply-templates select="key('key1_name',date)[generate-id()=generate-id('key2_name',concat(d ate,':',sender/sen_id,' ',sender/recipient/rec_id))]"/> (...) The complete stylesheet: <xsl:key match="header" name="key1_name" use="date"/> <xsl:key match="header" name="key2_name" use="concat(date,':',sender/sen_id,':',sender/recipient/rec_id)"/> <xsl:template match="report"> <xsl:text>Report: </xsl:text> <xsl:apply-templates mode="level1" select="header[generate-id()=generate-id(key('key1_name',date))]"/> </xsl:template> <xsl:template match="header" mode="level1"> <xsl:text>  </xsl:text> <xsl:value-of select="date"/> <xsl:text> </xsl:text> <xsl:apply-templates mode="level2" select="key('key1_name',date)[generate-id()=generate-id(key('key2_name',conc at(date,':',sender/sen_id,':',sender/recipient/rec_id)))]"/> </xsl:template> <xsl:template match="header" mode="level2"> <xsl:text>    TRADING PARTNER: "</xsl:text> <xsl:value-of select="sender/sen_id"/> <xsl:text>" </xsl:text> <xsl:text>      Documents sent </xsl:text> <xsl:value-of select="count(key('key2_name',concat(date,':',sender/sen_id,' ',sender/recipient/rec_id)))"/> <xsl:text> </xsl:text> <xsl:text>      Documents REC'D </xsl:text> <xsl:value-of select="sender/recipient/rec_id"/> <xsl:text> </xsl:text> </xsl:template> Hope this helps you. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] A more complicated Muench, Greg Johnson | Thread | RE: [xsl] A more complicated Muench, Greg Johnson |
RE: [xsl] A more complicated Muench, Greg Johnson | Date | RE: [xsl] Removing empty element ta, Américo Albuquerque |
Month |