<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8;"/>
      <title>Address Book</title>
    </head>
    <body>
      <xsl:apply-templates/>
    </body>
  </html>
</xsl:template>

<xsl:template match="book">
  <table cellpadding="5">
    <caption style="font-size:1.5em">2 Cards</caption>
    <xsl:apply-templates select="vcard"/>
  </table>
</xsl:template>

<xsl:template match="vcard">
  <tr>
    <td>
      <table cellpadding="5" style="font-family:Georgia; border:solid">
        <caption style="font-size:1.25em; margin-bottom:1em;">
          <xsl:value-of select="fn"/>
        </caption>
        <tr>
          <td valign="top" align="center"><img src="http://digitalsushi.com/xslt/unh.gif"/></td>
          <td><xsl:apply-templates select="adr"/></td>
        </tr>
        <tr>
          <td style="font-size:1.25em">
            <p>
              <xsl:apply-templates select="fn"/>
              <br/>
              <xsl:apply-templates select="title"/>
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <ul>
              <xsl:apply-templates select="tel"/>
            </ul>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</xsl:template>

<xsl:template match="adr">
  <p>
    <xsl:apply-templates select="street-address"/>
    <br/>
    <xsl:apply-templates select="locality"/>
    <xsl:apply-templates select="region"/>
    <xsl:apply-templates select="postal-code"/>
    <br/>
    <xsl:apply-templates select="org"/>
  </p>
</xsl:template>

<xsl:template match="street-address">
  <div class="street-address">
    <xsl:value-of select="book/vcard/adr/street-address"/>
  </div>
</xsl:template>

<xsl:template match="locality">
  <span class="locality">
    <xsl:value-of select="/book/vcard/adr/locality"/>
  </span>,
</xsl:template>

<xsl:template match="region">
  <span class="region">
    <xsl:value-of select="/book/vcard/adr/region"/>
  </span> 
</xsl:template>

<xsl:template match="postal-code">
  <span class="postal-code">
    <xsl:value-of select="/book/vcard/adr/postal-code"/>
  </span>
</xsl:template>

<xsl:template match="org">
  <div class="org">
    <xsl:value-of select="/book/vcard/org"/>
  </div>
</xsl:template>

<xsl:template match="fn">
  <span class="fn">
    <xsl:value-of select="/book/vcard/fn"/>
  </span>
</xsl:template>

<xsl:template match="/book/vcard/title">
  <span class="title">
    <xsl:value-of select="title"/>
  </span>
</xsl:template>

<xsl:template match="email">
  <img src="http://digitalsushi.com/xslt/icn-email.gif"/>
  <a class="email">
    <xsl:value-of select="/book/vcard/email"/>
  </a>
</xsl:template>

<xsl:template match="url">
  <a class="url">
    <xsl:value-of select="/book/vcard/url"/>
  </a>
</xsl:template>

<xsl:template match="tel">
  <li>
    <xsl:value-of select="/book/vcard/tel"/>
  </li>
</xsl:template>

</xsl:stylesheet>
