XSLT terminado
[curso-xml.git] / catalogo.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2 <xsl:stylesheet version="1.0"
3     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
5 <xsl:template match="/">
6   <html>
7     <table border="1">
8         <tr bgcolor="#aaaaff">
9             <th>Titulo</th>
10             <th>Artista</th>
11             <th>Valoracion</th>
12         </tr>
13         <xsl:for-each select="catalogo/cd">
14             <xsl:sort select="@valoracion" order="descending" data-type="number"/>
15           <tr>
16              <xsl:choose>
17                  <xsl:when test="precio &gt; 15">
18                      <td bgcolor="#ffaaaa"><xsl:apply-templates select="titulo"/></td>
19                  </xsl:when>
20                  <xsl:when test="precio &lt; 10">
21                      <td bgcolor="#aaffaa"><xsl:apply-templates select="titulo"/></td>
22                  </xsl:when>
23                  <xsl:otherwise>
24                      <td><xsl:apply-templates select="titulo"/></td>
25                  </xsl:otherwise>
26              </xsl:choose>
27              <td><xsl:apply-templates select="artista"/></td>
28              <td><xsl:value-of select="@valoracion"/></td>
29           </tr>
30         </xsl:for-each>
31     </table>
32   </html>
33 </xsl:template>
34
35 <xsl:template match="titulo|artista">
36     <u><xsl:apply-templates/></u>
37 </xsl:template>
38
39 </xsl:stylesheet>