Subject: [xsl] Grouping by Deparment From: "Langdon, Jeffrey" <jlangdon@xxxxxxxxxxxx> Date: Tue, 16 Oct 2001 16:40:17 -0400 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] About xsl-editors@w3.org, B. Tommie Usdin | Thread | Re: [xsl] Grouping by Deparment, Jörg Heinicke |
[xsl] About xsl-editors@w3.org, B. Tommie Usdin | Date | RE: [xsl] extracting part of an att, Jennifer Wrightsell |
Month |