Mercurial > pycweather
comparison share/template.xsl @ 8:5e26e170a121
version 0.3.0
| author | Vlad Glagolev <enqlave@gmail.com> |
|---|---|
| date | Mon, 26 Dec 2011 11:08:09 +0400 |
| parents | a754b01955c7 |
| children |
comparison
equal
deleted
inserted
replaced
| 7:100d7f29aa6f | 8:5e26e170a121 |
|---|---|
| 1 <?xml version="1.0" encoding="UTF-8"?> | 1 <?xml version="1.0" encoding="UTF-8"?> |
| 2 <!-- pycweather/template.xsl: XSL stylesheet for displaying weather | 2 <!-- pycweather/template.xsl: XSL stylesheet for displaying weather |
| 3 | 3 |
| 4 This file is part of PycWeather | 4 This file is part of PycWeather |
| 5 | 5 |
| 6 Copyright (c) 2009 Vlad Glagolev <enqlave@gmail.com>. All rights reserved. | 6 Copyright (c) 2009-2011 Vlad Glagolev <enqlave@gmail.com>. All rights reserved. |
| 7 | 7 |
| 8 Permission to use, copy, modify, and distribute this software for any | 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 | 9 purpose with or without fee is hereby granted, provided that the above |
| 10 copyright notice and this permission notice appear in all copies. | 10 copyright notice and this permission notice appear in all copies. |
| 11 | 11 |
| 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 19 | 19 |
| 20 --> | 20 --> |
| 21 <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | 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"/> | 22 <xsl:output method="text" disable-output-escaping="yes"/> |
| 23 <!-- new line --> | |
| 23 <xsl:variable name="nl"> | 24 <xsl:variable name="nl"> |
| 24 <xsl:text> </xsl:text> | 25 <xsl:text> </xsl:text> |
| 25 </xsl:variable> | 26 </xsl:variable> |
| 26 <xsl:template match="weather"> | 27 <!-- extract image ID --> |
| 27 <xsl:apply-templates select="cc"/> | 28 <xsl:template name="getCondition"> |
| 28 <xsl:apply-templates select="dayf"/> | 29 <xsl:param name="filename"/> |
| 29 <xsl:comment>PycWeather</xsl:comment> | 30 <xsl:choose> |
| 31 <xsl:when test="contains($filename, '/')"> | |
| 32 <xsl:call-template name="getCondition"> | |
| 33 <xsl:with-param name="filename" select="substring-after($filename, '/')"/> | |
| 34 </xsl:call-template> | |
| 35 </xsl:when> | |
| 36 <xsl:otherwise> | |
| 37 <xsl:value-of select="$filename"/> | |
| 38 </xsl:otherwise> | |
| 39 </xsl:choose> | |
| 30 </xsl:template> | 40 </xsl:template> |
| 31 <xsl:template match="cc"> | 41 <!-- main block --> |
| 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"/> | 42 <xsl:template match="channel"> |
| 33 <xsl:text>Temperature: </xsl:text><xsl:value-of select="tmp"/>°<xsl:value-of select="../head/ut"/><xsl:value-of select="$nl"/> | 43 <xsl:comment>PycWeather 0.3.0</xsl:comment> |
| 34 <xsl:if test="tmp != flik"> | 44 <xsl:text>Location: </xsl:text><xsl:value-of select="normalize-space(substring-before(title, '- AccuWeather.com'))"/><xsl:value-of select="$nl"/> |
| 35 <xsl:text>Windchill: </xsl:text><xsl:value-of select="flik"/>°<xsl:value-of select="../head/ut"/><xsl:value-of select="$nl"/> | 45 <xsl:text>Update Time: </xsl:text><xsl:value-of select="pubDate"/> |
| 36 </xsl:if> | 46 <!-- don't parse info field --> |
| 37 <xsl:text>Conditions: </xsl:text><xsl:value-of select="t"/><xsl:value-of select="$nl"/> | 47 <xsl:apply-templates select="child::item[position() != last()]"/> |
| 38 <xsl:text>Wind: </xsl:text> | 48 </xsl:template> |
| 49 <!-- day field --> | |
| 50 <xsl:template match="item"> | |
| 51 <xsl:value-of select="$nl"/> | |
| 52 <xsl:variable name="condition"> | |
| 53 <xsl:call-template name="getCondition"> | |
| 54 <xsl:with-param name="filename" select="substring-before(description, '_')"/> | |
| 55 </xsl:call-template> | |
| 56 </xsl:variable> | |
| 57 <!-- convert image ID to ConkyWeather font character --> | |
| 39 <xsl:choose> | 58 <xsl:choose> |
| 40 <xsl:when test="wind/s = 'calm'"> | 59 <xsl:when test="number($condition) = 1"> |
| 60 <xsl:text>a</xsl:text> | |
| 61 </xsl:when> | |
| 62 <xsl:when test="number($condition) = 2"> | |
| 63 <xsl:text>b</xsl:text> | |
| 64 </xsl:when> | |
| 65 <xsl:when test="number($condition) = 3"> | |
| 66 <xsl:text>c</xsl:text> | |
| 67 </xsl:when> | |
| 68 <xsl:when test="number($condition) = 4"> | |
| 69 <xsl:text>c</xsl:text> | |
| 70 </xsl:when> | |
| 71 <xsl:when test="number($condition) = 5"> | |
| 72 <xsl:text>c</xsl:text> | |
| 73 </xsl:when> | |
| 74 <xsl:when test="number($condition) = 6"> | |
| 75 <xsl:text>d</xsl:text> | |
| 76 </xsl:when> | |
| 77 <xsl:when test="number($condition) = 7"> | |
| 78 <xsl:text>e</xsl:text> | |
| 79 </xsl:when> | |
| 80 <xsl:when test="number($condition) = 8"> | |
| 81 <xsl:text>e</xsl:text> | |
| 82 </xsl:when> | |
| 83 <xsl:when test="$condition = 11"> | |
| 41 <xsl:text>0</xsl:text> | 84 <xsl:text>0</xsl:text> |
| 42 </xsl:when> | 85 </xsl:when> |
| 86 <xsl:when test="$condition = 12"> | |
| 87 <xsl:text>h</xsl:text> | |
| 88 </xsl:when> | |
| 89 <xsl:when test="$condition = 13 or $condition = 14"> | |
| 90 <xsl:text>g</xsl:text> | |
| 91 </xsl:when> | |
| 92 <xsl:when test="$condition = 15"> | |
| 93 <xsl:text>l</xsl:text> | |
| 94 </xsl:when> | |
| 95 <xsl:when test="$condition = 16 or $condition = 17"> | |
| 96 <xsl:text>k</xsl:text> | |
| 97 </xsl:when> | |
| 98 <xsl:when test="$condition = 18 or $condition = 26"> | |
| 99 <xsl:text>i</xsl:text> | |
| 100 </xsl:when> | |
| 101 <xsl:when test="$condition = 19"> | |
| 102 <xsl:text>p</xsl:text> | |
| 103 </xsl:when> | |
| 104 <xsl:when test="$condition = 20 or $condition = 21 or $condition = 23"> | |
| 105 <xsl:text>o</xsl:text> | |
| 106 </xsl:when> | |
| 107 <xsl:when test="$condition = 22"> | |
| 108 <xsl:text>r</xsl:text> | |
| 109 </xsl:when> | |
| 110 <xsl:when test="$condition = 24 or $condition = 31"> | |
| 111 <xsl:text>E</xsl:text> | |
| 112 </xsl:when> | |
| 113 <xsl:when test="$condition = 25"> | |
| 114 <xsl:text>u</xsl:text> | |
| 115 </xsl:when> | |
| 116 <xsl:when test="$condition = 29"> | |
| 117 <xsl:text>v</xsl:text> | |
| 118 </xsl:when> | |
| 119 <xsl:when test="$condition = 30"> | |
| 120 <xsl:text>5</xsl:text> | |
| 121 </xsl:when> | |
| 122 <xsl:when test="$condition = 32"> | |
| 123 <xsl:text>6</xsl:text> | |
| 124 </xsl:when> | |
| 125 <xsl:when test="$condition = 33"> | |
| 126 <xsl:text>A</xsl:text> | |
| 127 </xsl:when> | |
| 128 <xsl:when test="$condition = 34 or $condition = 36 or $condition = 37"> | |
| 129 <xsl:text>B</xsl:text> | |
| 130 </xsl:when> | |
| 131 <xsl:when test="$condition = 35 or $condition = 38"> | |
| 132 <xsl:text>C</xsl:text> | |
| 133 </xsl:when> | |
| 134 <xsl:when test="$condition = 39 or $condition = 40"> | |
| 135 <xsl:text>G</xsl:text> | |
| 136 </xsl:when> | |
| 137 <xsl:when test="$condition = 41 or $condition = 42"> | |
| 138 <xsl:text>K</xsl:text> | |
| 139 </xsl:when> | |
| 140 <xsl:when test="$condition = 43 or $condition = 44"> | |
| 141 <xsl:text>O</xsl:text> | |
| 142 </xsl:when> | |
| 143 <!-- N/A --> | |
| 43 <xsl:otherwise> | 144 <xsl:otherwise> |
| 44 <xsl:value-of select="wind/s"/> | 145 <xsl:text>-</xsl:text> |
| 45 </xsl:otherwise> | 146 </xsl:otherwise> |
| 46 </xsl:choose> | 147 </xsl:choose> |
| 47 <xsl:value-of select="../head/us"/> | 148 <xsl:text> -- </xsl:text> |
| 48 <xsl:text> (</xsl:text><xsl:value-of select="wind/t"/><xsl:text>)</xsl:text> | 149 <xsl:value-of select="title"/> |
| 49 </xsl:template> | 150 <xsl:if test="position() != 1"> |
| 50 <!-- MULTIPLE DAYS DISPLAY --> | 151 <xsl:text>: </xsl:text> |
| 51 <xsl:template match="dayf"> | 152 <xsl:value-of select="substring-before(description, '<')"/> |
| 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> | 153 </xsl:if> |
| 81 </xsl:template> | 154 </xsl:template> |
| 82 </xsl:stylesheet> | 155 </xsl:stylesheet> |
