I am trying to generate a 4 column directory, grouped by the 4 disciplines in my department. One XML file contains the entire group. Each element has a department tag. The construction of the directory would be the following:
Group each entry by discipline.
For each group, cycle through each entry. If the Rank equals Supervisor, fill out the supervisor DIV, otherwise keep generating a div for each person in the group.
Once all entries in the group are exhausted, construct the next column for the next group...
Keep going until all groups are exhausted.
I'm new to XSLT and really need help. I can create a key for each group, and cycle through the entries in the group, but I'm not sure how to cycle through the different groups.
My mark up is below.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="group" match="employee" use="dept" />
<xsl:template match="/">
<div id="directory">
<div class="man">
<h1>Manager</h1>
<h2>John Doe</h2>
</div>
<div class="group">
<xsl:for-each select="key('group', 'Mechanical')">
<xsl:sort select="name" order="ascending"/>
(I need a conditional here to check if rank = supervisor)
<div class="super">
<h1>Supervisor</h1>
<h2><xsl:value-of select="name"/></h2>
</div>
<div>
<p class="name"><xsl:value-of select="name"/></p>
<p class="ID"><xsl:value-of select="id"/></p>
</div>
</xsl:for-each>
</div>
XML Directory
<?xml version="1.0" encoding="ISO-8859-1" ?>
<directory>
<employee>
<dept></dept>
<rank>Manager</rank>
<name>John Doe</name>
<id>1234</id>
</employee>
<employee>
<dept>Mechanical</dept>
<rank>Supervisor</rank>
<name>Jane Doe</name>
<id>4321</id>
</employee>
<employee>
<dept>Mechanical</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
<employee>
<dept>Mechanical</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
<employee>
<dept>Civil</dept>
<rank>Supervisor</rank>
<name>Jane Doe</name>
<id>4321</id>
</employee>
<employee>
<dept>Civil</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
<employee>
<dept>Civil</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
<employee>
<dept>Electrical</dept>
<rank>Supervisor</rank>
<name>Jane Doe</name>
<id>4321</id>
</employee>
<employee>
<dept>Electrical</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
<employee>
<dept>Electrical</dept>
<rank>General</rank>
<name>Joe Doe</name>
<id>2314</id>
</employee>
</directory>
Output would look something like:

HTML should look something like:
<div id="directory">
<div class="man">
<h1>Manager</h1>
<h2>John Doe</h2>
</div>
<div class="group">
<div class="super">
<h1>Mechanical Supervisor</h1>
<h2>Supervisor Name</h2>
</div>
<div>
<p class="name">Mech employee name</p>
<p class="ID">Mech employee ID</p>
</div><!--end group A-->
<div class="group">
<div class="super">
<h1>CivilSupervisor</h1>
<h2>Supervisor Name</h2>
</div>
<div>
<p class="name">Civil employee name</p>
<p class="ID">Civil employee ID</p>
</div><!--end group B-->
<div class="group">
<div class="super">
<h1>Electrical Supervisor</h1>
<h2>Supervisor Name</h2>
</div>
<div>
<p class="name">Electrical employee name</p>
<p class="ID">Electrical employee ID</p>
</div><!--end group C-->
</div>
table-- however in your code you are generating onlydivs) -- so, excuse me, but I feel confused. I am not that good in HTML and without knowing the exact wanted output I could generate XML with subtrees for each group and sorted children (superv., members).