Mercurial > pycweather
annotate 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 |
| rev | line source |
|---|---|
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
2 <!-- pycweather/template.xsl: XSL stylesheet for displaying weather |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
3 |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
4 This file is part of PycWeather |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
5 |
| 8 | 6 Copyright (c) 2009-2011 Vlad Glagolev <enqlave@gmail.com>. All rights reserved. |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
7 |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
8 Permission to use, copy, modify, and distribute this software for any |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
9 purpose with or without fee is hereby granted, provided that the above |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
10 copyright notice and this permission notice appear in all copies. |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
11 |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
12 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
13 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
14 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
15 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
19 |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
20 --> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
21 <xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
22 <xsl:output method="text" disable-output-escaping="yes"/> |
| 8 | 23 <!-- new line --> |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
24 <xsl:variable name="nl"> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
25 <xsl:text> </xsl:text> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
26 </xsl:variable> |
| 8 | 27 <!-- extract image ID --> |
| 28 <xsl:template name="getCondition"> | |
| 29 <xsl:param name="filename"/> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
30 <xsl:choose> |
| 8 | 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> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
35 </xsl:when> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
36 <xsl:otherwise> |
| 8 | 37 <xsl:value-of select="$filename"/> |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
38 </xsl:otherwise> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
39 </xsl:choose> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
40 </xsl:template> |
| 8 | 41 <!-- main block --> |
| 42 <xsl:template match="channel"> | |
| 43 <xsl:comment>PycWeather 0.3.0</xsl:comment> | |
| 44 <xsl:text>Location: </xsl:text><xsl:value-of select="normalize-space(substring-before(title, '- AccuWeather.com'))"/><xsl:value-of select="$nl"/> | |
| 45 <xsl:text>Update Time: </xsl:text><xsl:value-of select="pubDate"/> | |
| 46 <!-- don't parse info field --> | |
| 47 <xsl:apply-templates select="child::item[position() != last()]"/> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
48 </xsl:template> |
| 8 | 49 <!-- day field --> |
| 50 <xsl:template match="item"> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
51 <xsl:value-of select="$nl"/> |
| 8 | 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 --> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
58 <xsl:choose> |
| 8 | 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"> | |
| 84 <xsl:text>0</xsl:text> | |
| 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> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
100 </xsl:when> |
| 8 | 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 --> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
144 <xsl:otherwise> |
| 8 | 145 <xsl:text>-</xsl:text> |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
146 </xsl:otherwise> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
147 </xsl:choose> |
| 8 | 148 <xsl:text> -- </xsl:text> |
| 149 <xsl:value-of select="title"/> | |
| 150 <xsl:if test="position() != 1"> | |
| 151 <xsl:text>: </xsl:text> | |
| 152 <xsl:value-of select="substring-before(description, '<')"/> | |
|
3
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
153 </xsl:if> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
154 </xsl:template> |
|
a754b01955c7
1st stage of work for final 0.2.0
Vlad Glagolev <enqlave@gmail.com>
parents:
diff
changeset
|
155 </xsl:stylesheet> |
