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

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

somehow usable version of the overview page xsl

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