source: josm/trunk/styles/standard/overview.xsl@ 703

Last change on this file since 703 was 703, checked in by (none), 17 years ago

backup copy (incomplete):
experimental stylesheet to generate "map legend" (or better to say JOSM mappaint legend) from elemstyles.xml

File size: 9.3 KB
Line 
1<?xml version="1.0" encoding="iso-8859-1"?>
2<xsl:stylesheet
3 version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:html="http://www.w3.org/1999/xhtml"
6 exclude-result-prefixes="html"
7>
8
9 <xsl:output
10 method="xml"
11 indent="yes"
12 encoding="UTF-8"
13 />
14
15
16
17
18
19<xsl:template name="rule">
20 <xsl:param name="inpos" />
21 <xsl:param name="xpos" />
22 <xsl:param name="ypos" />
23
24
25 <xsl:variable name="xoutpos">
26 <xsl:choose>
27 <xsl:when test="$xpos &gt;= 100"><xsl:value-of select="$xpos" /></xsl:when>
28 <xsl:when test="$xpos &gt;= 10">0<xsl:value-of select="$xpos" /></xsl:when>
29 <xsl:otherwise>00<xsl:value-of select="$xpos" /></xsl:otherwise>
30 </xsl:choose>
31 </xsl:variable>
32
33 <xsl:variable name="youtpos">
34 <xsl:choose>
35 <xsl:when test="$ypos &gt;= 100"><xsl:value-of select="$ypos" /></xsl:when>
36 <xsl:when test="$ypos &gt;= 10">0<xsl:value-of select="$ypos" /></xsl:when>
37 <xsl:otherwise>00<xsl:value-of select="$ypos" /></xsl:otherwise>
38 </xsl:choose>
39 </xsl:variable>
40
41 <xsl:element name="node">
42 <xsl:attribute name="id">-<xsl:value-of select="$xpos" />000<xsl:value-of select="$ypos" /></xsl:attribute>
43 <xsl:attribute name="user">overview-creator</xsl:attribute>
44 <xsl:attribute name="visible">true</xsl:attribute>
45 <xsl:attribute name="lat">-0.0<xsl:value-of select="$youtpos" /></xsl:attribute>
46 <xsl:attribute name="lon">0.0<xsl:value-of select="$xoutpos" /></xsl:attribute>
47
48 <xsl:element name="tag">
49 <xsl:attribute name="k"><xsl:value-of select = "rule[$inpos]/condition/@k" /></xsl:attribute>
50 <xsl:attribute name="v"><xsl:value-of select = "rule[$inpos]/condition/@v" /></xsl:attribute>
51 </xsl:element>
52 <xsl:element name="tag">
53 <xsl:attribute name="k">name</xsl:attribute>
54 <xsl:attribute name="v"><xsl:value-of select = "rule[$inpos]/condition/@v" /></xsl:attribute>
55 </xsl:element>
56 </xsl:element>
57</xsl:template>
58
59
60<xsl:template name="posed_rules">
61
62 <xsl:param name="key"/>
63 <xsl:param name="inpos"/>
64 <xsl:param name="xpos"/>
65 <xsl:param name="ypos"/>
66
67 <xsl:if test="rule[$inpos]/condition/@k=$key">
68 <xsl:call-template name="rule">
69 <xsl:with-param name="inpos" select="$inpos"/>
70 <xsl:with-param name="xpos" select="$xpos"/>
71 <xsl:with-param name="ypos" select="$ypos"/>
72 </xsl:call-template>
73
74 <!-- recursive call - increasing in- and output counters -->
75 <xsl:call-template name="posed_rules">
76 <xsl:with-param name="key" select="$key"/>
77 <xsl:with-param name="inpos" select="$inpos + 1"/>
78 <xsl:with-param name="xpos" select="$xpos"/>
79 <xsl:with-param name="ypos" select="$ypos + 1"/>
80 </xsl:call-template>
81 </xsl:if>
82
83 <xsl:if test="rule[$inpos]/condition/@k!=$key">
84 <!-- recursive call - only increasing the in-counter -->
85 <xsl:call-template name="posed_rules">
86 <xsl:with-param name="key" select="$key"/>
87 <xsl:with-param name="inpos" select="$inpos + 1"/>
88 <xsl:with-param name="xpos" select="$xpos"/>
89 <xsl:with-param name="ypos" select="$ypos"/>
90 </xsl:call-template>
91 </xsl:if>
92
93</xsl:template>
94
95
96<xsl:template name="key_rules">
97 <xsl:param name="key"/>
98 <xsl:param name="xpos"/>
99
100 <!-- header item -->
101 <xsl:variable name="xoutpos">
102 <xsl:choose>
103 <xsl:when test="$xpos &gt;= 100"><xsl:value-of select="$xpos" /></xsl:when>
104 <xsl:when test="$xpos &gt;= 10">0<xsl:value-of select="$xpos" /></xsl:when>
105 <xsl:otherwise>00<xsl:value-of select="$xpos" /></xsl:otherwise>
106 </xsl:choose>
107 </xsl:variable>
108
109 <xsl:element name="node">
110 <xsl:attribute name="id">-<xsl:value-of select="$xpos" />0000</xsl:attribute>
111 <xsl:attribute name="user">overview-creator</xsl:attribute>
112 <xsl:attribute name="visible">true</xsl:attribute>
113 <xsl:attribute name="lat">-0.0</xsl:attribute>
114 <xsl:attribute name="lon">0.0<xsl:value-of select="$xoutpos" /></xsl:attribute>
115
116 <xsl:element name="tag">
117 <xsl:attribute name="k"><xsl:value-of select = "'tourism'" /></xsl:attribute>
118 <xsl:attribute name="v"><xsl:value-of select = "'attraction'" /></xsl:attribute>
119 </xsl:element>
120 <xsl:element name="tag">
121 <xsl:attribute name="k">name</xsl:attribute>
122 <xsl:attribute name="v"><xsl:value-of select = "$key" /></xsl:attribute>
123 </xsl:element>
124 </xsl:element>
125
126 <!-- key related items -->
127 <xsl:call-template name="posed_rules">
128 <xsl:with-param name="key" select="$key"/>
129 <xsl:with-param name="inpos" select="1"/>
130 <xsl:with-param name="xpos" select="$xpos"/>
131 <xsl:with-param name="ypos" select="1"/>
132 </xsl:call-template>
133</xsl:template>
134
135
136<xsl:template match="rules">
137
138 <xsl:element name="osm">
139 <xsl:attribute name="version">0.5</xsl:attribute>
140 <xsl:attribute name="generator">overview-creator.xslt</xsl:attribute>
141
142
143 <xsl:call-template name="key_rules">
144 <xsl:with-param name="key" select="'highway'"/>
145 <xsl:with-param name="xpos" select="1"/>
146 </xsl:call-template>
147
148 <xsl:call-template name="key_rules">
149 <xsl:with-param name="key" select="'cycleway'"/>
150 <xsl:with-param name="xpos" select="2"/>
151 </xsl:call-template>
152
153 <xsl:call-template name="key_rules">
154 <xsl:with-param name="key" select="'tracktype'"/>
155 <xsl:with-param name="xpos" select="3"/>
156 </xsl:call-template>
157
158 <xsl:call-template name="key_rules">
159 <xsl:with-param name="key" select="'waterway'"/>
160 <xsl:with-param name="xpos" select="4"/>
161 </xsl:call-template>
162
163 <xsl:call-template name="key_rules">
164 <xsl:with-param name="key" select="'railway'"/>
165 <xsl:with-param name="xpos" select="5"/>
166 </xsl:call-template>
167
168 <xsl:call-template name="key_rules">
169 <xsl:with-param name="key" select="'aeroway'"/>
170 <xsl:with-param name="xpos" select="6"/>
171 </xsl:call-template>
172
173 <xsl:call-template name="key_rules">
174 <xsl:with-param name="key" select="'aerialway'"/>
175 <xsl:with-param name="xpos" select="7"/>
176 </xsl:call-template>
177
178 <xsl:call-template name="key_rules">
179 <xsl:with-param name="key" select="'power'"/>
180 <xsl:with-param name="xpos" select="8"/>
181 </xsl:call-template>
182
183 <xsl:call-template name="key_rules">
184 <xsl:with-param name="key" select="'man_made'"/>
185 <xsl:with-param name="xpos" select="9"/>
186 </xsl:call-template>
187
188 <xsl:call-template name="key_rules">
189 <xsl:with-param name="key" select="'leisure'"/>
190 <xsl:with-param name="xpos" select="10"/>
191 </xsl:call-template>
192
193 <xsl:call-template name="key_rules">
194 <xsl:with-param name="key" select="'amenity'"/>
195 <xsl:with-param name="xpos" select="11"/>
196 </xsl:call-template>
197
198 <xsl:call-template name="key_rules">
199 <xsl:with-param name="key" select="'shop'"/>
200 <xsl:with-param name="xpos" select="12"/>
201 </xsl:call-template>
202
203 <xsl:call-template name="key_rules">
204 <xsl:with-param name="key" select="'tourism'"/>
205 <xsl:with-param name="xpos" select="13"/>
206 </xsl:call-template>
207
208 <xsl:call-template name="key_rules">
209 <xsl:with-param name="key" select="'historic'"/>
210 <xsl:with-param name="xpos" select="14"/>
211 </xsl:call-template>
212
213 <xsl:call-template name="key_rules">
214 <xsl:with-param name="key" select="'landuse'"/>
215 <xsl:with-param name="xpos" select="15"/>
216 </xsl:call-template>
217
218 <xsl:call-template name="key_rules">
219 <xsl:with-param name="key" select="'military'"/>
220 <xsl:with-param name="xpos" select="16"/>
221 </xsl:call-template>
222
223 <xsl:call-template name="key_rules">
224 <xsl:with-param name="key" select="'natural'"/>
225 <xsl:with-param name="xpos" select="17"/>
226 </xsl:call-template>
227
228 <xsl:call-template name="key_rules">
229 <xsl:with-param name="key" select="'route'"/>
230 <xsl:with-param name="xpos" select="18"/>
231 </xsl:call-template>
232
233 <xsl:call-template name="key_rules">
234 <xsl:with-param name="key" select="'boundary'"/>
235 <xsl:with-param name="xpos" select="19"/>
236 </xsl:call-template>
237
238 <xsl:call-template name="key_rules">
239 <xsl:with-param name="key" select="'sport'"/>
240 <xsl:with-param name="xpos" select="20"/>
241 </xsl:call-template>
242
243 <xsl:call-template name="key_rules">
244 <xsl:with-param name="key" select="'abutters'"/>
245 <xsl:with-param name="xpos" select="21"/>
246 </xsl:call-template>
247
248 <xsl:call-template name="key_rules">
249 <xsl:with-param name="key" select="'access'"/>
250 <xsl:with-param name="xpos" select="22"/>
251 </xsl:call-template>
252
253 <xsl:call-template name="key_rules">
254 <xsl:with-param name="key" select="'bridge'"/>
255 <xsl:with-param name="xpos" select="23"/>
256 </xsl:call-template>
257
258 <xsl:call-template name="key_rules">
259 <xsl:with-param name="key" select="'junction'"/>
260 <xsl:with-param name="xpos" select="24"/>
261 </xsl:call-template>
262
263 <xsl:call-template name="key_rules">
264 <xsl:with-param name="key" select="'oneway'"/>
265 <xsl:with-param name="xpos" select="24"/>
266 </xsl:call-template>
267
268 <xsl:call-template name="key_rules">
269 <xsl:with-param name="key" select="'place'"/>
270 <xsl:with-param name="xpos" select="25"/>
271 </xsl:call-template>
272
273 <xsl:call-template name="key_rules">
274 <xsl:with-param name="key" select="'route'"/>
275 <xsl:with-param name="xpos" select="26"/>
276 </xsl:call-template>
277
278 <xsl:call-template name="key_rules">
279 <xsl:with-param name="key" select="'surface'"/>
280 <xsl:with-param name="xpos" select="27"/>
281 </xsl:call-template>
282
283 </xsl:element>
284</xsl:template>
285
286</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.