Subject: Re: [xsl] Grouping by Deparment From: Jörg Heinicke <joerg.heinicke@xxxxxx> Date: Wed, 17 Oct 2001 03:05:29 +0200 |
Hi Jeffrey, here a working version using 'Grouping with Muenchian Method'. More information about that do you get here: http://www.jenitennison.com/xslt/grouping/muenchian.html. Hope this helps, Joerg <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output indent="yes"/> <xsl:key name="departments" match="Table" use="Department"/> <xsl:template match="/"> <TREENODES> <xsl:for-each select="NewDataSet/Table[count(.|key('departments',Department)[1])=1]"> <TreeNode Text="{Department}"> <xsl:for-each select="key('departments',Department)"> <TreeNode Text="{Name}"/> </xsl:for-each> </TreeNode> </xsl:for-each> </TREENODES> </xsl:template> </xsl:stylesheet> ----- Original Message ----- From: "Langdon, Jeffrey" <jlangdon@xxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, October 16, 2001 10:40 PM Subject: [xsl] Grouping by Deparment > Calling all XSL Gurus :-) > > I need a push in the right direction. I have an XML file that includes > a list of employees and their respective departments. I need to loop > through the xml and sort the employees by department alphabetically. > > I am not sure how to make the (Name) TreeNode element a child element of > the (Department) TreeNode element and then populate all the employees > within that department. > > My brain hurts...any help would be appreciated. > > Regards, > > Jeff Langdon > > Here is what I have so far - > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version='1.0'> > <xsl:template match="/"> > <TREENODES> > <xsl:for-each > select="NewDataSet/Table"> > <xsl:element > name="TreeNode"> > > <xsl:attribute name="Text"> > > <xsl:value-of select="Department" /> > > </xsl:attribute> > </xsl:element> > <xsl:element > name="TreeNode"> > > <xsl:attribute name="Text"> > > <xsl:value-of select="Name" /> > > </xsl:attribute> > </xsl:element> > </xsl:for-each> > </TREENODES> > </xsl:template> > </xsl:stylesheet> > > Here is the XML file - > > <NewDataSet> > <Table> > <cn>Acevedo, Antonia</cn> > <Department>Dispatch-Freight</Department> > <Name>Acevedo, Antonia</Name> > </Table> > <Table> > <cn>Aimone, Charlie</cn> > <Department>IT</Department> > <Name>Aimone, Charlie</Name> > </Table> > <Table> > <cn>Arenas, Lizalyn</cn> > <Department>Dispatch-Freight</Department> > <Name>Arenas, Lizalyn</Name> > </Table> > <Table> > <cn>Arrendell, Miguel</cn> > <Department>Warehouse</Department> > <Name>Arrendell, Miguel</Name> > </Table> > <Table> > <cn>Bayron, Jun</cn> > <Department>Warehouse</Department> > <Name>Bayron, Jun</Name> > </Table> > <Table> > <cn>Belki Hercules</cn> > <Department>ITl</Department> > <Name>Belki Hercules</Name> > </Table> > </NewDataSet> > > Output I am looking for - > > <TREENODE> > <TreeNode Text="Dispatch-Frieght"> > <TreeNode Text="Acevedo, Antonia" /> > <TreeNode Text="Arenas, Lizalyn" /> > </TreeNode> > <TreeNode Text="IT"> > <TreeNode Text="Aimone, Charlie" /> > <TreeNode Text="Belki, Hercules" /> > </TreeNode> > <TreeNode Text="Warehouse"> > <TreeNode Text="Arrendell, Miguel" /> > <TreeNode Text="Bayron, Jun" /> > </TreeNode> > </TREENODE> > > > ********************************************************************** > This email and any files transmitted with it are confidential and > intended solely for the use of the individual or entity to whom they > are addressed. If you have received this email in error please notify > the system manager. > > This footnote also confirms that this email message has been swept by > MIMEsweeper for the presence of computer viruses. > > www.mimesweeper.com > ********************************************************************** > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Grouping by Deparment, Langdon, Jeffrey | Thread | RE: [xsl] Grouping by Deparment, Langdon, Jeffrey |
[xsl] accessing info outside curren, Pekarek, Rose (MN10) | Date | [xsl] Problem implementing grouping, Gary Bartlett |
Month |