[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: group using element in two different places in xml
I'll just repeat an earlier thread today: "You'll find the answer at http://www.jenitennison.com/xslt/grouping Michael Kay" Note that you may want to use a template approach rather than the for-each approach. Jeni's pages will teach you all about it. Of course, if you then still can't figger it out then you're always welcome to ask further. HTH, <prs/> -----Original Message----- From: James Steven [mailto:JSteven@xxxxxxxxxxxxxxxxxxxxx] Sent: Monday, July 05, 2004 10:19 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: group using element in two different places in xml Hello Currently I have a table which uses the xml and pseudo code shown below: <a> <b> <c> <d> <data> <info>group1</info> <info2>two</info2> <info3>three</info4> </data> <data> <info>group3</info> <info2>four</info2> <info3>five</info4> </data> <data> <info>group1</info> <info2>two</info2> <info3>five</info4> </data> <data2> <info>group1</info> <info2>two</info2> <info3>four</info4> </data2> <data2> <info>group2</info> <info2>two</info2> <info3>five</info4> </data2> <data2> <info>group3</info> <info2>three</info2> <info3>four</info4> </data2> </d> </c> </b> </a> <xsl:key name="entries" match="data" use="info"/> <xsl:key name="entries2" match="data2" use="info"/> <xsl:template match="a"/> <xsl:for-each select="d/data[generate-id(.)=generate-id(key('entries',info))] | d/data2[generate-id(.)=generate-id(key('entries2',info))] "> <xsl:for-each select="key('entries',info)"> <!--display value of each unique <info> as header and other elements in <data>--!> </xsl:for-each> <xsl:for-each select="key('entries2',info)"> <!--display other each unique <info> as header and other elements in <data2>--!> </xsl:for-each> </xsl:for-each> </xsl:template> The pseudo code above produces a table displaying each <data> and <data2> in whatever <info> group it has the same value as. The problem with this method is that it produces each <info> group twice as <xsl:for-each> adds both d/data and d/data2. How do I list each unique <info> and the <data> or <data2> that corresponds with it without duplicating? Thanks for any help. James --+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--
|
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
|