<!--
===============================
Lenguajes de Marcas
Bloque 5, actividad 5, parte 2.
Alumno: Miguel I. García López.
===============================
Enunciado:
"Generar un fichero XSL (p2.xsl) en el que se
muestre nombre, distribuidor y la foto (no el
nombre del fichero sino la imagen en sí) de todos
los productos."
La tabla se muestra ordenada por el nombre del producto.
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<!-- Definimos el nombre del programa de gestión y el copyright -->
<xsl:variable name="programa" select="'SuperMarket de Luxe v1.05'"/>
<xsl:variable name="copyright" select="'(c) 2014 Miguel García'"/>
<!-- Inicio de la salida HTML -->
<html>
<head>
<title>
Actividad 5.2: Miguel I. García López
</title>
<!-- Definición de estilos -->
<style>
body
{
font-family: Tahoma, Verdana, Arial, sans-serif;
text-align: center;
}
table, th, td
{
border-style: outset;
border-width: 2px;
border-color: black;
border-collapse:collapse;
}
th
{
font-family: "Times News Roman", serif;
font-variant: small-caps;
font-weight: bold;
font-size: medium;
color: white;
background-color: brown;
text-align: center;
}
td
{
font-family: Tahoma, Verdana, Arial, sans-serif;
font-size: small;
text-align: left;
}
</style>
</head>
<body>
<!-- Mostrar el logotipo del supermercado -->
<img src="{/productos/@logo}" alt="Logo del supermercado" />
<!-- Mostrar el nombre del supermercado entre corchetes -->
<h1>
[<xsl:value-of select="/productos/@supermercado"/>]
</h1>
<!-- Mostrar el título del informe, y el nº de productos listados -->
<h2>
Listado de productos, ordenados por nombre:
<xsl:value-of select="count(/productos/producto)"/> productos en total.
</h2>
<!-- Mostrar la tabla -->
<table style="width: 60%; margin-left: auto; margin-right: auto">
<!-- Mostrar las cabeceras -->
<tr>
<th>Producto</th>
<th>Distribuidor</th>
<th>Fotografía</th>
</tr>
<!-- Listar productos -->
<xsl:for-each select="productos/producto">
<!-- Ordenar por nombre del producto -->
<xsl:sort select="nombre"/>
<!-- Mostrar una fila por cada producto -->
<tr style="background-color: silver">
<!-- Mostrar el nombre -->
<td style="padding-left: 1em">
<xsl:value-of select="nombre"/>
</td>
<!-- Mostrar el nombre de la empresa distribuidora -->
<td style="padding-left: 1em">
<xsl:value-of select="distribuidor/empresa/razon_social"/>
</td>
<!-- Mostrar la imagen del producto -->
<td style="background-color: white; width: 96px; height: 96px">
<img src="{foto}" width="96" height="96" alt="Imagen de {nombre}"/>
</td>
</tr>
</xsl:for-each>
</table>
<!-- Mostrar el nombre del programa y copyright -->
<h2>
<xsl:value-of select="$programa"/> - <xsl:value-of select="$copyright"/>
</h2>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
No hay comentarios:
Publicar un comentario