Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="ISO-8859-15" ?>
- <!--
- fichero: meteo_1.xsl
- fecha: 20150402
- autor: ESTEBAN CERVERA MARCO ecm197626@hotmail.com
- proposito: Aprende XSLT paso a paso
- PASO 1: CREA UNA PLANTILLA BASE HTML PARA EL ELEMENTO RAIZ
- PASO 2: CREA UNA PLANTILLA PARA LOS REGISTROS HIJOS DEL ELEMENTO RAIZ Y VINCULALA A LA ANTERIOR
- PASO 3: UTILIZA ELEMENTOS XSL AVANZADOS
- PASO 4: A?ADE CSS
- -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:variable name="periodo_1-2">00-12</xsl:variable>
- <xsl:variable name="periodo_2-2">12-24</xsl:variable>
- <xsl:variable name="titulo">Predicción meteorológica</xsl:variable>
- <xsl:variable name="asignatura">CIPFP Mislata - DAMS1-LMI Lenguajes de marcas y sistemas de gestión de información"</xsl:variable>
- <xsl:template match="root">
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="css/meteo.css"/>
- <title>
- <xsl:copy-of select="$titulo"/>-<xsl:value-of select="nombre"/>(<xsl:value-of select="provincia"/>)
- </title>
- </head>
- <body>
- <table>
- <tr>
- <td colspan="6" class="faemet">
- <a target="_blank">
- <xsl:attribute name="href">
- <xsl:value-of select="./origen/web"/>
- </xsl:attribute>
- <img>
- <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/logo_AEMET_web.gif</xsl:attribute>
- <xsl:attribute name="title">
- <xsl:value-of select="origen/productor"/>
- </xsl:attribute>
- <xsl:attribute name="alt">
- <xsl:value-of select="origen/productor"/>
- </xsl:attribute>
- </img>
- </a>
- </td>
- <td colspan="5" class="letracentral">
- <div class="negrita">
- <xsl:copy-of select="$titulo"/>
- <br/>
- <xsl:value-of select="nombre"/>(<xsl:value-of select="provincia"/>)
- <br/>
- </div>
- <xsl:value-of select="elaborado"/>
- </td>
- <td colspan="3">
- <a target="_blank">
- <xsl:attribute name="href">http://fp.edu.gva.es/av/course/view.php?id=5327</xsl:attribute>
- <img>
- <xsl:attribute name="src">http://www.fpmislata.com/logos/logo_cipfpm_curt.png</xsl:attribute>
- <xsl:attribute name="height">70</xsl:attribute>
- <xsl:attribute name="title">
- <xsl:copy-of select="$asignatura"/>
- </xsl:attribute>
- <xsl:attribute name="alt">
- <xsl:value-of select="$asignatura"/>
- </xsl:attribute>
- </img>
- </a>
- </td>
- </tr>
- <tr class="tencabezado">
- <td>Fecha</td>
- <td>Franja horaria</td>
- <td>Estado del cielo</td>
- <td>Prob. precip</td>
- <td>Cota nieve prov.(m)</td>
- <td>Temp. min./máx. (ºC)</td>
- <td>Sen. térm.mín./máx(ºC)</td>
- <td>Hum. rel. mín./máx. (%)</td>
- <td>Viento (km/h)</td>
- <td>Racha máx. (km/h)</td>
- <td>Temp. (°C)</td>
- <td>Sen. térmica (°C)</td>
- <td>Humedad relativa (%)</td>
- <td>Indice UV máximo</td>
- </tr>
- <xsl:apply-templates select="prediccion/dia"/>
- <tr class="pie">
- <td colspan="14">
- <a target="_blank">
- <xsl:attribute name="href">
- <xsl:value-of select="./origen/nota_legal"/>
- </xsl:attribute>
- <xsl:attribute name="title">
- <xsl:copy-of select="./origen/copyright"/>
- </xsl:attribute>
- <p>
- <xsl:value-of select="origen/copyright"/>
- </p>
- </a>
- </td>
- </tr>
- </table>
- </body>
- </html>
- </xsl:template>
- <xsl:template match="prediccion/dia">
- <xsl:variable name="contadorPeriodos" select="count(estado_cielo)" />
- <xsl:choose>
- <xsl:when test='$contadorPeriodos = 1'>
- <tr class="celdas">
- <td colspan="2" class="tencabezadofecha">
- <span class="tencabezadofecha">
- <xsl:value-of select="@fecha"/>
- </span>
- </td>
- <xsl:apply-templates select="estado_cielo"/>
- <td>
- <xsl:value-of select="prob_precipitacion"/>%</td>
- <td>
- <xsl:value-of select="cota_nieve_prov"/>
- </td>
- <xsl:apply-templates select="temperatura"/>
- <xsl:apply-templates select="sens_termica"/>
- <xsl:apply-templates select="humedad_relativa"/>
- <xsl:apply-templates select="viento"/>
- <td>
- <xsl:value-of select="racha_max"/>
- </td>
- <td/>
- <td/>
- <td/>
- <td>
- <xsl:value-of select="uv_max"/>
- </td>
- </tr>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="temperatura">
- <td>
- <span class="negro">
- <xsl:value-of select="minima"/>
- </span>/
- <span class="rojo">
- <xsl:value-of select="maxima"/>
- </span>
- </td>
- </xsl:template>
- <xsl:template match="sens_termica">
- <td>
- <span class="negro">
- <xsl:value-of select="minima"/>
- </span>/<span class="rojo">
- <xsl:value-of select="maxima"/>
- </span>
- </td>
- </xsl:template>
- <xsl:template match="humedad_relativa">
- <td>
- <span class="negro">
- <xsl:value-of select="minima"/>
- </span>/<span class="rojo">
- <xsl:value-of select="maxima"/>
- </span>
- </td>
- </xsl:template>
- <xsl:template match="estado_cielo">
- <td>
- <img>
- <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/estado_cielo/<xsl:value-of select="../estado_cielo"/>.gif</xsl:attribute>
- <xsl:attribute name="title">
- <xsl:value-of select="@descripcion"/>
- </xsl:attribute>
- <xsl:attribute name="alt">
- <xsl:value-of select="@descripcion"/>
- </xsl:attribute>
- </img>
- </td>
- </xsl:template>
- <xsl:template match="viento">
- <td>
- <img>
- <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/iconos_viento/<xsl:value-of select="../viento/direccion"/>.gif</xsl:attribute>
- <xsl:attribute name="title">
- <xsl:value-of select="direccion"/>
- </xsl:attribute>
- <xsl:attribute name="alt">
- <xsl:value-of select="direccion"/>
- </xsl:attribute>
- </img>
- <br/>
- <xsl:value-of select="velocidad"/>
- </td>
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement