TITLE
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xhtml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" encoding="UTF-8" indent="yes" version="1.0"
omit-xml-declaration="yes"/>
<xsl:template match="/">
<html>
<head>
<style type="text/css">
#left {
float:left;
width:30%;
}
#right {
float:left;
width:70%;
}
.entrada {
border: 1px solid black;
width: 378px;
margin:10px;
}
.entrada_grupo {
border: 1px solid black;
width: 370px;
padding: 0px;
margin: 10px 0px 10px 0px;
background-color: #ffffff;
}
.grupo {
background-color: #ccccaa;
border: 1px solid black;
width: 378px;
margin:10px;
}
td h2 {
color:#123456;
font-style:italic;
}</style>
<title>Agenda de contactos</title>
</head>
<body>
<div id="left">
<h2>Lista de contactos</h2>
<xsl:apply-templates mode="indice"/>
<h2>Lista de contactos ordenada</h2>
<xsl:apply-templates mode="indiceord"/>
</div>
<div id="right">
<xsl:apply-templates/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="entrada" mode="indice">
<ul>
<li>
<a href="#{@id}">
<xsl:value-of select="nome"/>
</a>
</li>
</ul>
</xsl:template>
<xsl:template match="*" mode="indiceord">
<ul>
<xsl:for-each select="entrada|grupo/entrada">
<xsl:sort order="ascending" select="nome"/>
<li>
<a href="#{@id}">
<xsl:value-of select="nome"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="grupo">
<table class="grupo">
<th>
<h1>
<xsl:text>Grupo:</xsl:text>
<xsl:value-of select="@gid"/>
</h1>
</th>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="entrada">
<a name="{@id}"/>
<table class="entrada">
<th/>
<tr>
<td>
<xsl:choose>
<xsl:when test="@tipo='pessoa'">
<h2>
<xsl:text>Pessoa</xsl:text>
</h2>
</xsl:when>
<xsl:when test="@tipo='empresa'">
<h2>
<xsl:text>Empresa</xsl:text>
</h2>
</xsl:when>
<xsl:when test="not(@tipo)">
<h2>
<xsl:text>Sem tipo</xsl:text>
</h2>
</xsl:when>
</xsl:choose>
</td>
</tr>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="grupo/entrada">
<a name="{@id}"/>
<tr>
<td>
<table class="entrada_grupo">
<tr>
<td>
<xsl:choose>
<xsl:when test="@tipo='pessoa'">
<h2>
<xsl:text>Pessoa</xsl:text>
</h2>
</xsl:when>
<xsl:when test="@tipo='empresa'">
<h2>
<xsl:text>Empresa</xsl:text>
</h2>
</xsl:when>
<xsl:when test="not(@tipo)">
<h2>
<xsl:text>Sem tipo</xsl:text>
</h2>
</xsl:when>
</xsl:choose>
<xsl:apply-templates/>
</td>
</tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="ref">
<xsl:variable name="ENTREF" select="@entref"/>
<tr>
<td>
<xsl:text>Ver também:</xsl:text>
<a href="#{@entref}">
<xsl:value-of select="/agenda/entrada[@id = $ENTREF]/nome"/>
</a>
</td>
</tr>
</xsl:template>
<xsl:template match="nome">
<tr>
<td>
<xsl:apply-templates/>
</td>
</tr>
</xsl:template>
<xsl:template match="email">
<tr>
<td>
<a href="mailto:{.}">
<xsl:apply-templates/>
</a>
</td>
</tr>
</xsl:template>
<xsl:template match="telefone">
<tr>
<td>
<xsl:apply-templates/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>