Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. <?xml version="1.0" encoding="ISO-8859-15" ?>
  2.  
  3.  
  4. <!--
  5. fichero: meteo_1.xsl
  6. fecha: 20150402
  7. autor: ESTEBAN CERVERA MARCO ecm197626@hotmail.com
  8. proposito: Aprende XSLT paso a paso
  9. PASO 1: CREA UNA PLANTILLA BASE HTML PARA EL ELEMENTO RAIZ
  10. PASO 2: CREA UNA PLANTILLA PARA LOS REGISTROS HIJOS DEL ELEMENTO RAIZ Y VINCULALA A LA ANTERIOR
  11. PASO 3: UTILIZA ELEMENTOS XSL AVANZADOS
  12. PASO 4: A?ADE CSS
  13. -->
  14.  
  15. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  16. <xsl:variable name="periodo_1-2">00-12</xsl:variable>
  17. <xsl:variable name="periodo_2-2">12-24</xsl:variable>
  18. <xsl:variable name="titulo">Predicción meteorológica</xsl:variable>
  19. <xsl:variable name="asignatura">CIPFP Mislata - DAMS1-LMI Lenguajes de marcas y sistemas de gestión de información"</xsl:variable>
  20. <xsl:template match="root">
  21. <html>
  22.  
  23. <head>
  24. <link rel="stylesheet" type="text/css" href="css/meteo.css"/>
  25. <title>
  26. <xsl:copy-of select="$titulo"/>-<xsl:value-of select="nombre"/>(<xsl:value-of select="provincia"/>)
  27. </title>
  28. </head>
  29. <body>
  30. <table>
  31. <tr>
  32. <td colspan="6" class="faemet">
  33. <a target="_blank">
  34. <xsl:attribute name="href">
  35. <xsl:value-of select="./origen/web"/>
  36. </xsl:attribute>
  37. <img>
  38. <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/logo_AEMET_web.gif</xsl:attribute>
  39. <xsl:attribute name="title">
  40. <xsl:value-of select="origen/productor"/>
  41. </xsl:attribute>
  42. <xsl:attribute name="alt">
  43. <xsl:value-of select="origen/productor"/>
  44. </xsl:attribute>
  45.  
  46. </img>
  47.  
  48.  
  49. </a>
  50. </td>
  51. <td colspan="5" class="letracentral">
  52. <div class="negrita">
  53. <xsl:copy-of select="$titulo"/>
  54. <br/>
  55.  
  56. <xsl:value-of select="nombre"/>(<xsl:value-of select="provincia"/>)
  57. <br/>
  58. </div>
  59. <xsl:value-of select="elaborado"/>
  60.  
  61. </td>
  62. <td colspan="3">
  63. <a target="_blank">
  64. <xsl:attribute name="href">http://fp.edu.gva.es/av/course/view.php?id=5327</xsl:attribute>
  65. <img>
  66. <xsl:attribute name="src">http://www.fpmislata.com/logos/logo_cipfpm_curt.png</xsl:attribute>
  67. <xsl:attribute name="height">70</xsl:attribute>
  68. <xsl:attribute name="title">
  69. <xsl:copy-of select="$asignatura"/>
  70. </xsl:attribute>
  71. <xsl:attribute name="alt">
  72. <xsl:value-of select="$asignatura"/>
  73. </xsl:attribute>
  74. </img>
  75.  
  76.  
  77. </a>
  78.  
  79. </td>
  80. </tr>
  81. <tr class="tencabezado">
  82.  
  83. <td>Fecha</td>
  84. <td>Franja horaria</td>
  85. <td>Estado del cielo</td>
  86. <td>Prob. precip</td>
  87. <td>Cota nieve prov.(m)</td>
  88. <td>Temp. min./máx. (ºC)</td>
  89. <td>Sen. térm.mín./máx(ºC)</td>
  90. <td>Hum. rel. mín./máx. (%)</td>
  91. <td>Viento (km/h)</td>
  92. <td>Racha máx. (km/h)</td>
  93. <td>Temp. (°C)</td>
  94. <td>Sen. térmica (°C)</td>
  95. <td>Humedad relativa (%)</td>
  96. <td>Indice UV máximo</td>
  97.  
  98. </tr>
  99. <xsl:apply-templates select="prediccion/dia"/>
  100.  
  101. <tr class="pie">
  102.  
  103. <td colspan="14">
  104. <a target="_blank">
  105. <xsl:attribute name="href">
  106. <xsl:value-of select="./origen/nota_legal"/>
  107. </xsl:attribute>
  108. <xsl:attribute name="title">
  109. <xsl:copy-of select="./origen/copyright"/>
  110. </xsl:attribute>
  111. <p>
  112. <xsl:value-of select="origen/copyright"/>
  113. </p>
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. </a>
  121. </td>
  122.  
  123.  
  124. </tr>
  125.  
  126. </table>
  127.  
  128. </body>
  129.  
  130. </html>
  131. </xsl:template>
  132. <xsl:template match="prediccion/dia">
  133.  
  134. <xsl:variable name="contadorPeriodos" select="count(estado_cielo)" />
  135. <xsl:choose>
  136.  
  137.  
  138. <xsl:when test='$contadorPeriodos = 1'>
  139.  
  140. <tr class="celdas">
  141.  
  142. <td colspan="2" class="tencabezadofecha">
  143. <span class="tencabezadofecha">
  144. <xsl:value-of select="@fecha"/>
  145. </span>
  146. </td>
  147.  
  148. <xsl:apply-templates select="estado_cielo"/>
  149.  
  150.  
  151. <td>
  152. <xsl:value-of select="prob_precipitacion"/>%</td>
  153. <td>
  154. <xsl:value-of select="cota_nieve_prov"/>
  155. </td>
  156.  
  157.  
  158. <xsl:apply-templates select="temperatura"/>
  159.  
  160.  
  161.  
  162. <xsl:apply-templates select="sens_termica"/>
  163.  
  164. <xsl:apply-templates select="humedad_relativa"/>
  165. <xsl:apply-templates select="viento"/>
  166.  
  167. <td>
  168. <xsl:value-of select="racha_max"/>
  169. </td>
  170. <td/>
  171. <td/>
  172. <td/>
  173. <td>
  174. <xsl:value-of select="uv_max"/>
  175. </td>
  176. </tr>
  177.  
  178.  
  179. </xsl:when>
  180. </xsl:choose>
  181.  
  182.  
  183.  
  184. </xsl:template>
  185. <xsl:template match="temperatura">
  186. <td>
  187. <span class="negro">
  188. <xsl:value-of select="minima"/>
  189. </span>/
  190.  
  191.  
  192.  
  193. <span class="rojo">
  194. <xsl:value-of select="maxima"/>
  195. </span>
  196.  
  197. </td>
  198. </xsl:template>
  199. <xsl:template match="sens_termica">
  200. <td>
  201. <span class="negro">
  202. <xsl:value-of select="minima"/>
  203. </span>/<span class="rojo">
  204. <xsl:value-of select="maxima"/>
  205. </span>
  206. </td>
  207. </xsl:template>
  208. <xsl:template match="humedad_relativa">
  209. <td>
  210. <span class="negro">
  211. <xsl:value-of select="minima"/>
  212. </span>/<span class="rojo">
  213. <xsl:value-of select="maxima"/>
  214. </span>
  215. </td>
  216. </xsl:template>
  217. <xsl:template match="estado_cielo">
  218. <td>
  219. <img>
  220. <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/estado_cielo/<xsl:value-of select="../estado_cielo"/>.gif</xsl:attribute>
  221. <xsl:attribute name="title">
  222. <xsl:value-of select="@descripcion"/>
  223. </xsl:attribute>
  224. <xsl:attribute name="alt">
  225. <xsl:value-of select="@descripcion"/>
  226. </xsl:attribute>
  227. </img>
  228.  
  229.  
  230. </td>
  231. </xsl:template>
  232. <xsl:template match="viento">
  233.  
  234. <td>
  235. <img>
  236. <xsl:attribute name="src">http://www.aemet.es/imagenes/gif/iconos_viento/<xsl:value-of select="../viento/direccion"/>.gif</xsl:attribute>
  237. <xsl:attribute name="title">
  238. <xsl:value-of select="direccion"/>
  239. </xsl:attribute>
  240. <xsl:attribute name="alt">
  241. <xsl:value-of select="direccion"/>
  242.  
  243.  
  244. </xsl:attribute>
  245. </img>
  246. <br/>
  247. <xsl:value-of select="velocidad"/>
  248. </td>
  249. </xsl:template>
  250.  
  251. </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement