<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8"/>
<xsl:template match="/AddressBook">
<html>
<head>
<LINK href="techlab.css" TYPE="text/css" REL="stylesheet"></LINK>
<title>Contact Management System [XSL Listing of AddressBook.xml]</title>
</head>
<body>
<h3>Listing from the XML Address Book</h3>
<span class="BodyCopy">Here's some data from the XML file that contains the address book.</span>
<table width="100%" border="1">
<tr bgcolor="#eeeeee"><th width="100">Name</th><th width="55">Nickname</th><th width="100">Home phone</th><th width="100">Cell phone</th><th width="100">Business phone</th><th width="120">Email </th><th width="70">Home city</th><th width="75">Birthday </th><th width="100">Spouse  name</th><th width="20"># of<br></br>chil- dren</th></tr>
<!--Loop through the data in my addressbook-->
<xsl:for-each select="Contact">
<xsl:sort select="PrimaryInfo/Name/Last" order="ascending" case-order="upper-first"/>
<tr>
<td><xsl:value-of select="PrimaryInfo//Name"/>
</td>
<td><xsl:value-of select="PrimaryInfo/Name/@Nickname"/></td>
<td><xsl:value-of select="Addresses/Home/Phones/Landline"/></td>
<td><xsl:value-of select="Addresses/Home/Phones/Mobile"/></td>
<td><xsl:value-of select="Addresses/Work/WorkPhones"/></td>
<td><xsl:value-of select="PrimaryInfo/Email/WorkEmail"/></td>
<td><xsl:value-of select="Addresses/Home/HomeAddress/City"/></td>
<td><xsl:value-of select="Dates/Birthday"/></td>

<td>
<xsl:choose>
	<xsl:when test="PersonalInfo/Spouse"><xsl:value-of select="PersonalInfo/Spouse"/></xsl:when>

	<xsl:otherwise>None</xsl:otherwise>
</xsl:choose>	
	</td>

<td>
<xsl:choose>
	<xsl:when test="PersonalInfo/Children"><xsl:value-of select="count(PersonalInfo/Children)"/></xsl:when>
	<xsl:otherwise>None</xsl:otherwise>
</xsl:choose>

</td>
</tr>											
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>