[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Grouping by Deparment

Subject: Grouping by Deparment
From: "Langdon, Jeffrey" <jlangdon@xxxxxxxxxxxx>
Date: Tue, 16 Oct 2001 16:40:17 -0400
treenode text xml
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.