Mercurial > pycweather
comparison share/template.xsl @ 3:a754b01955c7
1st stage of work for final 0.2.0
| author | Vlad Glagolev <enqlave@gmail.com> |
|---|---|
| date | Mon, 27 Jul 2009 00:02:10 +0400 |
| parents | |
| children | 5e26e170a121 |
comparison
equal
deleted
inserted
replaced
| 2:bf34534a0acd | 3:a754b01955c7 |
|---|---|
| 1 <?xml version="1.0" encoding="UTF-8"?> | |
| 2 <!-- pycweather/template.xsl: XSL stylesheet for displaying weather | |
| 3 | |
| 4 This file is part of PycWeather | |
| 5 | |
| 6 Copyright (c) 2009 Vlad Glagolev <enqlave@gmail.com>. All rights reserved. | |
| 7 | |
| 8 Permission to use, copy, modify, and distribute this software for any | |
| 9 purpose with or without fee is hereby granted, provided that the above | |
| 10 copyright notice and this permission notice appear in all copies. | |
| 11 | |
| 12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
| 13 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
| 14 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
| 15 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
| 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 19 | |
| 20 --> | |
| 21 <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
| 22 <xsl:output method="text" disable-output-escaping="yes"/> | |
| 23 <xsl:variable name="nl"> | |
| 24 <xsl:text> </xsl:text> | |
| 25 </xsl:variable> | |
| 26 <xsl:template match="weather"> | |
| 27 <xsl:apply-templates select="cc"/> | |
| 28 <xsl:apply-templates select="dayf"/> | |
| 29 <xsl:comment>PycWeather</xsl:comment> | |
| 30 </xsl:template> | |
| 31 <xsl:template match="cc"> | |
| 32 <xsl:text>Location: </xsl:text><xsl:value-of select="obst"/><xsl:text> (</xsl:text><xsl:value-of select="../loc/lat"/><xsl:text>, </xsl:text><xsl:value-of select="../loc/lon"/><xsl:text>)</xsl:text><xsl:value-of select="$nl"/> | |
| 33 <xsl:text>Temperature: </xsl:text><xsl:value-of select="tmp"/>°<xsl:value-of select="../head/ut"/><xsl:value-of select="$nl"/> | |
| 34 <xsl:if test="tmp != flik"> | |
| 35 <xsl:text>Windchill: </xsl:text><xsl:value-of select="flik"/>°<xsl:value-of select="../head/ut"/><xsl:value-of select="$nl"/> | |
| 36 </xsl:if> | |
| 37 <xsl:text>Conditions: </xsl:text><xsl:value-of select="t"/><xsl:value-of select="$nl"/> | |
| 38 <xsl:text>Wind: </xsl:text> | |
| 39 <xsl:choose> | |
| 40 <xsl:when test="wind/s = 'calm'"> | |
| 41 <xsl:text>0</xsl:text> | |
| 42 </xsl:when> | |
| 43 <xsl:otherwise> | |
| 44 <xsl:value-of select="wind/s"/> | |
| 45 </xsl:otherwise> | |
| 46 </xsl:choose> | |
| 47 <xsl:value-of select="../head/us"/> | |
| 48 <xsl:text> (</xsl:text><xsl:value-of select="wind/t"/><xsl:text>)</xsl:text> | |
| 49 </xsl:template> | |
| 50 <!-- MULTIPLE DAYS DISPLAY --> | |
| 51 <xsl:template match="dayf"> | |
| 52 <!-- don't repeat the first one --> | |
| 53 <xsl:apply-templates select="child::day[position() > 1]"/> | |
| 54 </xsl:template> | |
| 55 <xsl:template match="day"> | |
| 56 <xsl:value-of select="$nl"/> | |
| 57 <xsl:value-of select="@dt"/><xsl:text>, </xsl:text><xsl:value-of select="@t"/> | |
| 58 <xsl:if test="@d = 1"> | |
| 59 <xsl:text> (Tomorrow)</xsl:text> | |
| 60 </xsl:if> | |
| 61 <xsl:text>: </xsl:text> | |
| 62 <xsl:apply-templates select="part"/> | |
| 63 </xsl:template> | |
| 64 <xsl:template match="part"> | |
| 65 <xsl:choose> | |
| 66 <xsl:when test="@p = 'd'"> | |
| 67 <xsl:text>Day (</xsl:text> | |
| 68 <xsl:value-of select="../hi"/>°<xsl:value-of select="../../../head/ut"/> | |
| 69 </xsl:when> | |
| 70 <xsl:otherwise> | |
| 71 <xsl:text>Night (</xsl:text> | |
| 72 <xsl:value-of select="../low"/>°<xsl:value-of select="../../../head/ut"/> | |
| 73 </xsl:otherwise> | |
| 74 </xsl:choose> | |
| 75 <xsl:text>, </xsl:text> | |
| 76 <xsl:apply-templates select="t"/> | |
| 77 <xsl:text>)</xsl:text> | |
| 78 <xsl:if test="@p = 'd'"> | |
| 79 <xsl:text>; </xsl:text> | |
| 80 </xsl:if> | |
| 81 </xsl:template> | |
| 82 </xsl:stylesheet> |
