Merge lp:~leonardr/launchpadlib/remove-xslt into lp:launchpadlib
- remove-xslt
- Merge into trunk
Proposed by
Leonard Richardson
Status: | Merged |
---|---|
Approved by: | Curtis Hovey |
Approved revision: | 107 |
Merged at revision: | 108 |
Proposed branch: | lp:~leonardr/launchpadlib/remove-xslt |
Merge into: | lp:launchpadlib |
Diff against target: |
1089 lines (+6/-1068) 2 files modified
src/launchpadlib/NEWS.txt (+6/-0) src/launchpadlib/wadl-to-refhtml.xsl (+0/-1068) |
To merge this branch: | bzr merge lp:~leonardr/launchpadlib/remove-xslt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | code | Approve | |
j.c.sackett (community) | code* | Approve | |
Review via email: mp+46167@code.launchpad.net |
Commit message
Description of the change
This branch removes the XSLT used to turn Launchpad's WADL into HTML documentation. It's now been moved back into Launchpad.
To post a comment you must log in.
- 107. By Leonard Richardson
-
Merge from trunk, remove stylesheet.
Revision history for this message
Curtis Hovey (sinzui) wrote : | # |
This is good to land
review:
Approve
(code)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/launchpadlib/NEWS.txt' | |||
2 | --- src/launchpadlib/NEWS.txt 2011-01-10 19:11:16 +0000 | |||
3 | +++ src/launchpadlib/NEWS.txt 2011-01-13 19:17:34 +0000 | |||
4 | @@ -2,6 +2,12 @@ | |||
5 | 2 | NEWS for launchpadlib | 2 | NEWS for launchpadlib |
6 | 3 | ===================== | 3 | ===================== |
7 | 4 | 4 | ||
8 | 5 | Unreleased | ||
9 | 6 | ========== | ||
10 | 7 | |||
11 | 8 | - The XSLT stylesheet for converting the Launchpad WADL into HTML | ||
12 | 9 | documentation has been moved back into Launchpad. | ||
13 | 10 | |||
14 | 5 | 1.9.3 (2011-01-10) | 11 | 1.9.3 (2011-01-10) |
15 | 6 | ================== | 12 | ================== |
16 | 7 | 13 | ||
17 | 8 | 14 | ||
18 | === removed file 'src/launchpadlib/wadl-to-refhtml.xsl' | |||
19 | --- src/launchpadlib/wadl-to-refhtml.xsl 2010-12-02 15:00:24 +0000 | |||
20 | +++ src/launchpadlib/wadl-to-refhtml.xsl 1970-01-01 00:00:00 +0000 | |||
21 | @@ -1,1068 +0,0 @@ | |||
22 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
23 | 2 | <!-- | ||
24 | 3 | wadl-to-refhtml.xsl | ||
25 | 4 | |||
26 | 5 | Generate HTML documentation for a webservice described in a WADL file. | ||
27 | 6 | This is tailored to WADL generated by Launchpad's web service. | ||
28 | 7 | |||
29 | 8 | Based on wadl_documentaion.xsl from Mark Nottingham <mnot@yahoo-inc.com> | ||
30 | 9 | that can be found at http://www.mnot.net/webdesc/ | ||
31 | 10 | Copyright (c) 2006-2007 Yahoo! Inc. | ||
32 | 11 | Copyright (c) 2008 Canonical Ltd. | ||
33 | 12 | |||
34 | 13 | This work is licensed under the Creative Commons Attribution-ShareAlike 2.5 | ||
35 | 14 | License. To view a copy of this license, visit | ||
36 | 15 | http://creativecommons.org/licenses/by-sa/2.5/ | ||
37 | 16 | or send a letter to | ||
38 | 17 | Creative Commons | ||
39 | 18 | 543 Howard Street, 5th Floor | ||
40 | 19 | San Francisco, California, 94105, USA | ||
41 | 20 | --> | ||
42 | 21 | |||
43 | 22 | <xsl:stylesheet | ||
44 | 23 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" | ||
45 | 24 | xmlns:wadl="http://research.sun.com/wadl/2006/10" | ||
46 | 25 | xmlns:html="http://www.w3.org/1999/xhtml" | ||
47 | 26 | xmlns="http://www.w3.org/1999/xhtml" | ||
48 | 27 | exclude-result-prefixes="xsl wadl html" | ||
49 | 28 | > | ||
50 | 29 | <xsl:output | ||
51 | 30 | method="xml" | ||
52 | 31 | encoding="UTF-8" | ||
53 | 32 | indent="yes" | ||
54 | 33 | doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
55 | 34 | doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" | ||
56 | 35 | /> | ||
57 | 36 | |||
58 | 37 | |||
59 | 38 | <!-- Allow using key('id', 'people') to identify unique elements, since | ||
60 | 39 | the document doesn't have a parsed DTD. | ||
61 | 40 | --> | ||
62 | 41 | <xsl:key name="id" match="*[@id]" use="@id"/> | ||
63 | 42 | |||
64 | 43 | <!-- Embedded stylesheet. --> | ||
65 | 44 | <xsl:template name="css-stylesheet"> | ||
66 | 45 | <style type="text/css"> | ||
67 | 46 | body { | ||
68 | 47 | font-family: sans-serif; | ||
69 | 48 | font-size: 0.85em; | ||
70 | 49 | margin: 2em 8em; | ||
71 | 50 | } | ||
72 | 51 | .methods { | ||
73 | 52 | background-color: #eef; | ||
74 | 53 | padding: 1em; | ||
75 | 54 | margin-bottom: 0.5em; | ||
76 | 55 | } | ||
77 | 56 | .method { | ||
78 | 57 | padding-left: 4em; | ||
79 | 58 | } | ||
80 | 59 | h1 { | ||
81 | 60 | font-size: 2.5em; | ||
82 | 61 | } | ||
83 | 62 | h2 { | ||
84 | 63 | border-bottom: 1px solid black; | ||
85 | 64 | margin-top: 1em; | ||
86 | 65 | margin-bottom: 0.5em; | ||
87 | 66 | font-size: 2em; | ||
88 | 67 | } | ||
89 | 68 | h3 { | ||
90 | 69 | color: orange; | ||
91 | 70 | font-size: 1.75em; | ||
92 | 71 | margin-top: 1.25em; | ||
93 | 72 | margin-bottom: 0em; | ||
94 | 73 | } | ||
95 | 74 | h4 { | ||
96 | 75 | font-size: 1.50em; | ||
97 | 76 | margin: 0em; | ||
98 | 77 | padding: 0em; | ||
99 | 78 | border-bottom: 2px solid white; | ||
100 | 79 | } | ||
101 | 80 | h5 { | ||
102 | 81 | font-size: 1.25em; | ||
103 | 82 | margin-left: -3em; | ||
104 | 83 | } | ||
105 | 84 | h6 { | ||
106 | 85 | font-size: 1.1em; | ||
107 | 86 | color: #99a; | ||
108 | 87 | margin: 0.5em 0em 0.25em 0em; | ||
109 | 88 | } | ||
110 | 89 | dd { | ||
111 | 90 | margin-left: 1em; | ||
112 | 91 | } | ||
113 | 92 | tt, code { | ||
114 | 93 | font-size: 1.2em; | ||
115 | 94 | } | ||
116 | 95 | table { | ||
117 | 96 | margin-bottom: 0.5em; | ||
118 | 97 | } | ||
119 | 98 | th { | ||
120 | 99 | text-align: left; | ||
121 | 100 | font-weight: normal; | ||
122 | 101 | color: black; | ||
123 | 102 | border-bottom: 1px solid black; | ||
124 | 103 | padding: 3px 6px; | ||
125 | 104 | } | ||
126 | 105 | td { | ||
127 | 106 | padding: 3px 6px; | ||
128 | 107 | vertical-align: top; | ||
129 | 108 | background-color: #f6f6ff; | ||
130 | 109 | font-size: 0.85em; | ||
131 | 110 | } | ||
132 | 111 | td p { | ||
133 | 112 | margin: 0px; | ||
134 | 113 | } | ||
135 | 114 | ul { | ||
136 | 115 | padding-left: 1.75em; | ||
137 | 116 | } | ||
138 | 117 | p + ul, p + ol, p + dl { | ||
139 | 118 | margin-top: 0em; | ||
140 | 119 | } | ||
141 | 120 | label { | ||
142 | 121 | font-weight: bold; | ||
143 | 122 | } | ||
144 | 123 | .optional { | ||
145 | 124 | font-weight: normal; | ||
146 | 125 | opacity: 0.75; | ||
147 | 126 | } | ||
148 | 127 | .toc-link { | ||
149 | 128 | font-size: 0.85em; | ||
150 | 129 | } | ||
151 | 130 | </style> | ||
152 | 131 | </xsl:template> | ||
153 | 132 | |||
154 | 133 | <!-- Contains the base URL for the webservice without a trailing | ||
155 | 134 | slash. --> | ||
156 | 135 | <xsl:variable name="base"> | ||
157 | 136 | <xsl:variable name="uri" select="//wadl:resources/@base"/> | ||
158 | 137 | <xsl:choose> | ||
159 | 138 | <xsl:when | ||
160 | 139 | test="substring($uri, string-length($uri) , 1) = '/'"> | ||
161 | 140 | <xsl:value-of | ||
162 | 141 | select="substring($uri, 1, string-length($uri) - 1)"/> | ||
163 | 142 | </xsl:when> | ||
164 | 143 | <xsl:otherwise> | ||
165 | 144 | <xsl:value-of select="$uri"/> | ||
166 | 145 | </xsl:otherwise> | ||
167 | 146 | </xsl:choose> | ||
168 | 147 | </xsl:variable> | ||
169 | 148 | |||
170 | 149 | <!-- Generate the URL to the top-level collection. --> | ||
171 | 150 | <xsl:template name="resource-uri-doc"> | ||
172 | 151 | <xsl:param name="url"><xsl:value-of | ||
173 | 152 | select="$base"/>/<xsl:value-of select="@id"/></xsl:param> | ||
174 | 153 | <p><label>URL:</label> | ||
175 | 154 | <code><xsl:copy-of select="$url" /></code></p> | ||
176 | 155 | </xsl:template> | ||
177 | 156 | |||
178 | 157 | <xsl:template name="entry-uri-doc"> | ||
179 | 158 | <xsl:call-template name="resource-uri-doc"> | ||
180 | 159 | <xsl:with-param name="url"> | ||
181 | 160 | <xsl:choose> | ||
182 | 161 | <xsl:when test="@id = 'has_milestones' | ||
183 | 162 | or @id = 'bug_target' | ||
184 | 163 | or @id = 'has_bugs'"> | ||
185 | 164 | <em>depends on the underlying entry</em> | ||
186 | 165 | </xsl:when> | ||
187 | 166 | <xsl:otherwise> | ||
188 | 167 | <xsl:call-template name="find-entry-uri"/> | ||
189 | 168 | </xsl:otherwise> | ||
190 | 169 | </xsl:choose> | ||
191 | 170 | </xsl:with-param> | ||
192 | 171 | </xsl:call-template> | ||
193 | 172 | </xsl:template> | ||
194 | 173 | |||
195 | 174 | <xsl:template name="find-entry-uri"> | ||
196 | 175 | <xsl:value-of select="$base"/> | ||
197 | 176 | <xsl:choose> | ||
198 | 177 | <xsl:when test="@id = 'archive'"> | ||
199 | 178 | <xsl:text>/</xsl:text> | ||
200 | 179 | <var><distribution></var> | ||
201 | 180 | <xsl:text>/+archive/</xsl:text> | ||
202 | 181 | <var><archive.name></var> | ||
203 | 182 | </xsl:when> | ||
204 | 183 | <xsl:when test="@id = 'archive_permission'"> | ||
205 | 184 | <xsl:text>/</xsl:text> | ||
206 | 185 | <var><archive.distribution></var> | ||
207 | 186 | <xsl:text>/+archive/</xsl:text> | ||
208 | 187 | <var><archive.name></var> | ||
209 | 188 | <xsl:text>/+</xsl:text> | ||
210 | 189 | <xsl:text>name</xsl:text> | ||
211 | 190 | <xsl:text>/</xsl:text> | ||
212 | 191 | <xsl:text>person.name</xsl:text> | ||
213 | 192 | <xsl:text>.</xsl:text> | ||
214 | 193 | <xsl:text>[component or source package].name</xsl:text> | ||
215 | 194 | </xsl:when> | ||
216 | 195 | <xsl:when test="@id = 'binary_package_publishing_history'"> | ||
217 | 196 | <xsl:text>/</xsl:text> | ||
218 | 197 | <var><distribution.name></var> | ||
219 | 198 | <xsl:text>/+archive/</xsl:text> | ||
220 | 199 | <var><binary_package.name></var> | ||
221 | 200 | <xsl:text>/+binarypub/</xsl:text> | ||
222 | 201 | <var><id></var> | ||
223 | 202 | </xsl:when> | ||
224 | 203 | <xsl:when test="@id = 'branch'"> | ||
225 | 204 | <xsl:text>/~</xsl:text> | ||
226 | 205 | <var><author.name></var> | ||
227 | 206 | <xsl:text>/</xsl:text> | ||
228 | 207 | <var><project.name></var> | ||
229 | 208 | <xsl:text>/</xsl:text> | ||
230 | 209 | <var><name></var> | ||
231 | 210 | </xsl:when> | ||
232 | 211 | <xsl:when test="@id = 'branch_merge_proposal'"> | ||
233 | 212 | <xsl:text>/~</xsl:text> | ||
234 | 213 | <var><author.name></var> | ||
235 | 214 | <xsl:text>/</xsl:text> | ||
236 | 215 | <var><project.name></var> | ||
237 | 216 | <xsl:text>/</xsl:text> | ||
238 | 217 | <var><branch.name></var> | ||
239 | 218 | <xsl:text>/+merge/</xsl:text> | ||
240 | 219 | <var><id></var> | ||
241 | 220 | </xsl:when> | ||
242 | 221 | <xsl:when test="@id = 'bug'"> | ||
243 | 222 | <xsl:text>/bugs/</xsl:text><var><id></var> | ||
244 | 223 | </xsl:when> | ||
245 | 224 | <xsl:when test="@id = 'bug_attachment'"> | ||
246 | 225 | <xsl:text>/bugs/</xsl:text> | ||
247 | 226 | <var><bug.id></var> | ||
248 | 227 | <xsl:text>/attachments/</xsl:text> | ||
249 | 228 | <var><id></var> | ||
250 | 229 | </xsl:when> | ||
251 | 230 | <xsl:when test="@id = 'bug_subscription'"> | ||
252 | 231 | <xsl:text>/bugs/</xsl:text> | ||
253 | 232 | <var><bug.id></var> | ||
254 | 233 | <xsl:text>/subscriptions/</xsl:text> | ||
255 | 234 | <var><subscriber.name></var> | ||
256 | 235 | </xsl:when> | ||
257 | 236 | <xsl:when test="@id = 'bug_task'"> | ||
258 | 237 | <xsl:text>/</xsl:text> | ||
259 | 238 | <var><target.name></var> | ||
260 | 239 | <xsl:text>/+bug/</xsl:text> | ||
261 | 240 | <var ><bug.id></var> | ||
262 | 241 | </xsl:when> | ||
263 | 242 | <xsl:when test="@id = 'bug_watch'"> | ||
264 | 243 | <xsl:text>/bugs/</xsl:text> | ||
265 | 244 | <var><bug.id></var> | ||
266 | 245 | <xsl:text>/watch/</xsl:text> | ||
267 | 246 | <var><id></var> | ||
268 | 247 | </xsl:when> | ||
269 | 248 | <xsl:when test="@id = 'bug_tracker'"> | ||
270 | 249 | <xsl:text>/bugs/bugtrackers/</xsl:text> | ||
271 | 250 | <var><name></var> | ||
272 | 251 | </xsl:when> | ||
273 | 252 | <xsl:when test="@id = 'build'"> | ||
274 | 253 | <xsl:text>/</xsl:text> | ||
275 | 254 | <var><distribution.name></var> | ||
276 | 255 | <xsl:text>/+source/</xsl:text> | ||
277 | 256 | <var><source_package.name></var> | ||
278 | 257 | <xsl:text>/+build/</xsl:text> | ||
279 | 258 | <var><id></var> | ||
280 | 259 | </xsl:when> | ||
281 | 260 | <xsl:when test="@id = 'cve'"> | ||
282 | 261 | <xsl:text>/bugs/cve/</xsl:text> | ||
283 | 262 | <var><sequence></var> | ||
284 | 263 | </xsl:when> | ||
285 | 264 | <xsl:when test="@id = 'distribution_source_package'"> | ||
286 | 265 | <xsl:text>/</xsl:text> | ||
287 | 266 | <var><distribution.name></var> | ||
288 | 267 | <xsl:text>/+source/</xsl:text> | ||
289 | 268 | <var><name></var> | ||
290 | 269 | </xsl:when> | ||
291 | 270 | <xsl:when test="@id = 'distro_arch_series'"> | ||
292 | 271 | <xsl:text>/</xsl:text> | ||
293 | 272 | <var><distribution.name></var> | ||
294 | 273 | <xsl:text>/</xsl:text> | ||
295 | 274 | <var><distroseries.name></var> | ||
296 | 275 | <xsl:text>/</xsl:text> | ||
297 | 276 | <var><architecture_tag></var> | ||
298 | 277 | </xsl:when> | ||
299 | 278 | <xsl:when test="@id = 'distro_series'"> | ||
300 | 279 | <xsl:text>/</xsl:text> | ||
301 | 280 | <var><distribution.name></var> | ||
302 | 281 | <xsl:text>/</xsl:text> | ||
303 | 282 | <var><name></var> | ||
304 | 283 | </xsl:when> | ||
305 | 284 | <xsl:when test="@id = 'email_address'"> | ||
306 | 285 | <xsl:text>/</xsl:text> | ||
307 | 286 | <var><person.name></var> | ||
308 | 287 | <xsl:text>/+email/</xsl:text> | ||
309 | 288 | <var><email></var> | ||
310 | 289 | </xsl:when> | ||
311 | 290 | <xsl:when test="@id = 'h_w_device'"> | ||
312 | 291 | <xsl:text>/+hwdb/+device/</xsl:text> | ||
313 | 292 | <var><id></var> | ||
314 | 293 | </xsl:when> | ||
315 | 294 | <xsl:when test="@id = 'h_w_device_class'"> | ||
316 | 295 | <xsl:text>/+hwdb/+deviceclass/</xsl:text> | ||
317 | 296 | <var><id></var> | ||
318 | 297 | </xsl:when> | ||
319 | 298 | <xsl:when test="@id = 'h_w_driver'"> | ||
320 | 299 | <xsl:text>/+hwdb/+driver/</xsl:text> | ||
321 | 300 | <var><id></var> | ||
322 | 301 | </xsl:when> | ||
323 | 302 | <xsl:when test="@id = 'h_w_submission'"> | ||
324 | 303 | <xsl:text>/+hwdb/+submission/</xsl:text> | ||
325 | 304 | <var><submission-key></var> | ||
326 | 305 | </xsl:when> | ||
327 | 306 | <xsl:when test="@id = 'h_w_submission_device'"> | ||
328 | 307 | <xsl:text>/+hwdb/+submissiondevice/</xsl:text> | ||
329 | 308 | <var><id></var> | ||
330 | 309 | </xsl:when> | ||
331 | 310 | <xsl:when test="@id = 'h_w_vendor_i_d'"> | ||
332 | 311 | <xsl:text>/+hwdb/+hwvendorid/</xsl:text> | ||
333 | 312 | <var><id></var> | ||
334 | 313 | </xsl:when> | ||
335 | 314 | <xsl:when test="@id = 'jabber_id'"> | ||
336 | 315 | <xsl:text>/</xsl:text> | ||
337 | 316 | <var><person.name></var> | ||
338 | 317 | <xsl:text>/+jabberid/</xsl:text> | ||
339 | 318 | <var><id></var> | ||
340 | 319 | </xsl:when> | ||
341 | 320 | <xsl:when test="@id = 'irc_id'"> | ||
342 | 321 | <xsl:text>/</xsl:text> | ||
343 | 322 | <var><person.name></var> | ||
344 | 323 | <xsl:text>/+ircnick/</xsl:text> | ||
345 | 324 | <var><id></var> | ||
346 | 325 | </xsl:when> | ||
347 | 326 | <xsl:when test="@id = 'language'"> | ||
348 | 327 | <xsl:text>/+languages/</xsl:text> | ||
349 | 328 | <var><code></var> | ||
350 | 329 | </xsl:when> | ||
351 | 330 | <xsl:when test="@id = 'message'"> | ||
352 | 331 | <xsl:text>/</xsl:text> | ||
353 | 332 | <var><target.name></var> | ||
354 | 333 | <xsl:text>/+bug/</xsl:text> | ||
355 | 334 | <var><bug.id></var> | ||
356 | 335 | <xsl:text>/comments/</xsl:text> | ||
357 | 336 | <var><index></var> | ||
358 | 337 | </xsl:when> | ||
359 | 338 | <xsl:when test="@id = 'milestone'"> | ||
360 | 339 | <xsl:text>/</xsl:text> | ||
361 | 340 | <var><target.name></var> | ||
362 | 341 | <xsl:text>/+milestone/</xsl:text> | ||
363 | 342 | <var><name></var> | ||
364 | 343 | </xsl:when> | ||
365 | 344 | <xsl:when test=" @id = 'distribution' | ||
366 | 345 | or @id = 'pillar' | ||
367 | 346 | or @id = 'product' | ||
368 | 347 | or @id = 'project' | ||
369 | 348 | or @id = 'project_group'"> | ||
370 | 349 | <xsl:text>/</xsl:text> | ||
371 | 350 | <var><name></var> | ||
372 | 351 | </xsl:when> | ||
373 | 352 | <xsl:when test="@id = 'team' or @id = 'person'"> | ||
374 | 353 | <xsl:text>/~</xsl:text> | ||
375 | 354 | <var><name></var> | ||
376 | 355 | </xsl:when> | ||
377 | 356 | <xsl:when test="@id = 'product_release'"> | ||
378 | 357 | <xsl:text>/</xsl:text> | ||
379 | 358 | <var><product.name></var> | ||
380 | 359 | <xsl:text>/</xsl:text> | ||
381 | 360 | <var><product_series.name></var> | ||
382 | 361 | <xsl:text>/</xsl:text> | ||
383 | 362 | <var><name></var> | ||
384 | 363 | </xsl:when> | ||
385 | 364 | <xsl:when test="@id = 'product_series'"> | ||
386 | 365 | <xsl:text>/</xsl:text> | ||
387 | 366 | <var><product.name></var> | ||
388 | 367 | <xsl:text>/</xsl:text> | ||
389 | 368 | <var><name></var> | ||
390 | 369 | </xsl:when> | ||
391 | 370 | <xsl:when test="@id = 'project_release'"> | ||
392 | 371 | <xsl:text>/</xsl:text> | ||
393 | 372 | <var><project.name></var> | ||
394 | 373 | <xsl:text>/</xsl:text> | ||
395 | 374 | <var><project_series.name></var> | ||
396 | 375 | <xsl:text>/</xsl:text> | ||
397 | 376 | <var><release.version></var> | ||
398 | 377 | </xsl:when> | ||
399 | 378 | <xsl:when test="@id = 'project_release_file'"> | ||
400 | 379 | <xsl:text>/</xsl:text> | ||
401 | 380 | <var><project.name></var> | ||
402 | 381 | <xsl:text>/</xsl:text> | ||
403 | 382 | <var><project_series.name></var> | ||
404 | 383 | <xsl:text>/</xsl:text> | ||
405 | 384 | <var><release.version></var> | ||
406 | 385 | <xsl:text>/+file/</xsl:text> | ||
407 | 386 | <var><hosted_file.filename></var> | ||
408 | 387 | </xsl:when> | ||
409 | 388 | <xsl:when test="@id = 'project_series'"> | ||
410 | 389 | <xsl:text>/</xsl:text> | ||
411 | 390 | <var><project.name></var> | ||
412 | 391 | <xsl:text>/</xsl:text> | ||
413 | 392 | <var><name></var> | ||
414 | 393 | </xsl:when> | ||
415 | 394 | <xsl:when test="@id = 'source_package'"> | ||
416 | 395 | <xsl:text>/</xsl:text> | ||
417 | 396 | <var><distribution.name></var> | ||
418 | 397 | <xsl:text>/</xsl:text> | ||
419 | 398 | <var><distro_series.name></var> | ||
420 | 399 | <xsl:text>/+source/</xsl:text> | ||
421 | 400 | <var><name></var> | ||
422 | 401 | </xsl:when> | ||
423 | 402 | <xsl:when test="@id = 'source_package_publishing_history'"> | ||
424 | 403 | <xsl:text>/</xsl:text> | ||
425 | 404 | <var><distribution></var> | ||
426 | 405 | <xsl:text>/+archive/</xsl:text> | ||
427 | 406 | <var><name></var> | ||
428 | 407 | <xsl:text>/+sourcepub/</xsl:text> | ||
429 | 408 | <var><id></var> | ||
430 | 409 | </xsl:when> | ||
431 | 410 | <xsl:when test="@id = 'team_membership'"> | ||
432 | 411 | <xsl:text>/~</xsl:text> | ||
433 | 412 | <var><team.name></var> | ||
434 | 413 | <xsl:text>/+member/</xsl:text> | ||
435 | 414 | <var><member.name></var> | ||
436 | 415 | </xsl:when> | ||
437 | 416 | <xsl:when test="@id = 'wiki_name'"> | ||
438 | 417 | <xsl:text>/~</xsl:text> | ||
439 | 418 | <var><person.name></var> | ||
440 | 419 | <xsl:text>/+wikiname/</xsl:text> | ||
441 | 420 | <var><id></var> | ||
442 | 421 | </xsl:when> | ||
443 | 422 | <xsl:when test="@id = 'commercial_subscription'"> | ||
444 | 423 | <xsl:text>/+commercialsubscription/</xsl:text> | ||
445 | 424 | <var><commercial_subscription.id></var> | ||
446 | 425 | </xsl:when> | ||
447 | 426 | <xsl:otherwise> | ||
448 | 427 | <xsl:message>Unknown entry URL: | ||
449 | 428 | <xsl:value-of select="@id" /> | ||
450 | 429 | </xsl:message> | ||
451 | 430 | </xsl:otherwise> | ||
452 | 431 | </xsl:choose> | ||
453 | 432 | </xsl:template> | ||
454 | 433 | <!-- We start here. --> | ||
455 | 434 | <xsl:template match="/wadl:application"> | ||
456 | 435 | <xsl:variable name="title"> | ||
457 | 436 | <xsl:choose> | ||
458 | 437 | <xsl:when test="wadl:doc[@title]"> | ||
459 | 438 | <xsl:value-of select="wadl:doc[@title][1]/@title"/> | ||
460 | 439 | </xsl:when> | ||
461 | 440 | <xsl:otherwise>Launchpad Web Service API</xsl:otherwise> | ||
462 | 441 | </xsl:choose> | ||
463 | 442 | </xsl:variable> | ||
464 | 443 | <html> | ||
465 | 444 | <head> | ||
466 | 445 | <title><xsl:value-of select="$title" /></title> | ||
467 | 446 | <xsl:call-template name="css-stylesheet"/> | ||
468 | 447 | </head> | ||
469 | 448 | <body> | ||
470 | 449 | <h1><xsl:value-of select="$title" /></h1> | ||
471 | 450 | <xsl:apply-templates select="wadl:doc"/> | ||
472 | 451 | |||
473 | 452 | <xsl:call-template name="table-of-contents" /> | ||
474 | 453 | <xsl:call-template name="top-level-objects" /> | ||
475 | 454 | <xsl:call-template name="entry-types" /> | ||
476 | 455 | </body> | ||
477 | 456 | </html> | ||
478 | 457 | </xsl:template> | ||
479 | 458 | |||
480 | 459 | <!-- Table of contents --> | ||
481 | 460 | <xsl:template name="table-of-contents"> | ||
482 | 461 | <div id="toc" title="toc"> | ||
483 | 462 | <h2>Table of Contents</h2> | ||
484 | 463 | <h3>Top-level objects</h3> | ||
485 | 464 | <ul> | ||
486 | 465 | <xsl:for-each | ||
487 | 466 | select="key('id', 'service-root-json')/wadl:param/wadl:link"> | ||
488 | 467 | <xsl:sort select="../@name" /> | ||
489 | 468 | |||
490 | 469 | <xsl:variable name="object_id" | ||
491 | 470 | select="substring-after(@resource_type, '#')" /> | ||
492 | 471 | <xsl:variable name="collection_link_name" | ||
493 | 472 | select="substring-before( | ||
494 | 473 | ../@name, '_collection_link')" /> | ||
495 | 474 | <xsl:variable name="entry_link_name" | ||
496 | 475 | select="substring-before( | ||
497 | 476 | ../@name, '_link')" /> | ||
498 | 477 | <xsl:if test="string-length($object_id) > 0"> | ||
499 | 478 | <li><a href="#{$object_id}"> | ||
500 | 479 | <xsl:choose> | ||
501 | 480 | <xsl:when test="$collection_link_name"> | ||
502 | 481 | <xsl:value-of select="$collection_link_name" /> | ||
503 | 482 | </xsl:when> | ||
504 | 483 | <xsl:otherwise> | ||
505 | 484 | <xsl:value-of select="$entry_link_name" /> | ||
506 | 485 | </xsl:otherwise> | ||
507 | 486 | </xsl:choose> | ||
508 | 487 | </a></li> | ||
509 | 488 | </xsl:if> | ||
510 | 489 | </xsl:for-each> | ||
511 | 490 | </ul> | ||
512 | 491 | <h3>Entry types</h3> | ||
513 | 492 | <ul> | ||
514 | 493 | <xsl:for-each select="wadl:resource_type[ | ||
515 | 494 | @id != 'service-root' | ||
516 | 495 | and @id != 'HostedFile' | ||
517 | 496 | and not(contains(@id, 'page-resource')) | ||
518 | 497 | ]"> | ||
519 | 498 | <xsl:sort select="@id" /> | ||
520 | 499 | <xsl:variable name="id" select="./@id"/> | ||
521 | 500 | <xsl:variable name="top_level_collections" | ||
522 | 501 | select="key('id', 'service-root-json')//@resource_type[ | ||
523 | 502 | substring-after(., '#') = $id]" /> | ||
524 | 503 | <xsl:if test="not($top_level_collections[contains(., $id)])"> | ||
525 | 504 | <li><a href="#{$id}"> | ||
526 | 505 | <xsl:call-template name="get-title-or-id"> | ||
527 | 506 | <xsl:with-param name="element" select="." /> | ||
528 | 507 | </xsl:call-template> | ||
529 | 508 | </a></li> | ||
530 | 509 | </xsl:if> | ||
531 | 510 | </xsl:for-each> | ||
532 | 511 | </ul> | ||
533 | 512 | </div> | ||
534 | 513 | </xsl:template> | ||
535 | 514 | |||
536 | 515 | <!-- Top level collections container --> | ||
537 | 516 | <xsl:template name="top-level-objects"> | ||
538 | 517 | <div id="top-level-objects" title="top-level-objects"> | ||
539 | 518 | <h2>Top-level objects</h2> | ||
540 | 519 | |||
541 | 520 | <!-- | ||
542 | 521 | Top-level objects are found in the WADL by | ||
543 | 522 | looking at the representation of the service-root resource | ||
544 | 523 | and processing all the resource-type linked from it. | ||
545 | 524 | --> | ||
546 | 525 | <xsl:for-each | ||
547 | 526 | select="key('id', 'service-root-json')/wadl:param/wadl:link"> | ||
548 | 527 | <xsl:sort select="../@name" /> | ||
549 | 528 | <xsl:variable name="object_id" | ||
550 | 529 | select="substring-after(@resource_type, '#')" /> | ||
551 | 530 | |||
552 | 531 | <xsl:apply-templates | ||
553 | 532 | select="key('id', $object_id)" | ||
554 | 533 | mode="top-level-objects" /> | ||
555 | 534 | </xsl:for-each> | ||
556 | 535 | </div> | ||
557 | 536 | </xsl:template> | ||
558 | 537 | |||
559 | 538 | <xsl:template name="find-root-object-uri"> | ||
560 | 539 | <xsl:value-of select="$base"/> | ||
561 | 540 | <xsl:choose> | ||
562 | 541 | <xsl:when test="@id = 'hwdb'"> | ||
563 | 542 | <xsl:text>/+hwdb</xsl:text> | ||
564 | 543 | </xsl:when> | ||
565 | 544 | <xsl:otherwise> | ||
566 | 545 | <xsl:text>/</xsl:text><xsl:value-of select="@id" /> | ||
567 | 546 | </xsl:otherwise> | ||
568 | 547 | </xsl:choose> | ||
569 | 548 | </xsl:template> | ||
570 | 549 | |||
571 | 550 | <!-- Documentation for one top-level-object --> | ||
572 | 551 | <xsl:template match="wadl:resource_type" mode="top-level-objects"> | ||
573 | 552 | <div id="{@id}" title="{@id}" class="top-level-object"> | ||
574 | 553 | <h3><xsl:call-template name="get-title-or-id"/></h3> | ||
575 | 554 | <xsl:apply-templates select="wadl:doc"/> | ||
576 | 555 | |||
577 | 556 | <xsl:call-template name="resource-uri-doc"> | ||
578 | 557 | <xsl:with-param name="url"> | ||
579 | 558 | <!-- The default URL schema used for root objects of | ||
580 | 559 | Launchpad's webservice is | ||
581 | 560 | |||
582 | 561 | [urlbase]/[root-object-name] | ||
583 | 562 | |||
584 | 563 | e.g, | ||
585 | 564 | |||
586 | 565 | https://api.launchpad.net/beta/bugs | ||
587 | 566 | |||
588 | 567 | while the HWDB application root's URL is | ||
589 | 568 | |||
590 | 569 | https://api.launchpad.net/beta/+hwdb | ||
591 | 570 | |||
592 | 571 | In other words, the URL for the HWDB application | ||
593 | 572 | root needs to be mangled in a form similar to | ||
594 | 573 | that used for non-root objects in the template | ||
595 | 574 | "find-entry-uri". | ||
596 | 575 | --> | ||
597 | 576 | |||
598 | 577 | <xsl:call-template name="find-root-object-uri"/> | ||
599 | 578 | </xsl:with-param> | ||
600 | 579 | </xsl:call-template> | ||
601 | 580 | |||
602 | 581 | <!-- All top-level collections support a GET without arguments | ||
603 | 582 | iterating over all the resources. | ||
604 | 583 | The type of the resource is found by looking at the href attribute | ||
605 | 584 | of the default representation. Link is in the form | ||
606 | 585 | <resource>-page. | ||
607 | 586 | --> | ||
608 | 587 | <div class="methods standard"> | ||
609 | 588 | <h4>Standard method</h4> | ||
610 | 589 | <xsl:variable name="default_get" | ||
611 | 590 | select="wadl:method[not(wadl:request)][1]" /> | ||
612 | 591 | <xsl:variable name="resource_type" | ||
613 | 592 | select="substring-after( | ||
614 | 593 | substring-before( | ||
615 | 594 | $default_get//wadl:representation[ | ||
616 | 595 | not(@mediaType)]/@href, '-page'), | ||
617 | 596 | '#')" /> | ||
618 | 597 | <dl> | ||
619 | 598 | <dt>GET</dt> | ||
620 | 599 | <dd>Response contains a <a href="#{$resource_type}" | ||
621 | 600 | ><xsl:call-template name="get-title-or-id"> | ||
622 | 601 | <xsl:with-param name="element" | ||
623 | 602 | select="key('id', $resource_type)" /> | ||
624 | 603 | </xsl:call-template></a> | ||
625 | 604 | collection.</dd> | ||
626 | 605 | </dl> | ||
627 | 606 | </div> | ||
628 | 607 | |||
629 | 608 | <xsl:call-template name="custom-GETs" /> | ||
630 | 609 | <xsl:call-template name="custom-POSTs" /> | ||
631 | 610 | <a href="#toc" class="toc-link">(back to Table of Contents)</a> | ||
632 | 611 | </div> | ||
633 | 612 | </xsl:template> | ||
634 | 613 | |||
635 | 614 | <!-- Documentation for the standard methods on an entry --> | ||
636 | 615 | <xsl:template name="standard-methods"> | ||
637 | 616 | <div id="{@id}-standard-methods" title="{@id}-standard-methods" class="methods standard"> | ||
638 | 617 | <h4>Standard methods</h4> | ||
639 | 618 | <dl> | ||
640 | 619 | <!-- Standard methods are the ones without a ws.op param. --> | ||
641 | 620 | <xsl:apply-templates | ||
642 | 621 | select="wadl:method[not(.//wadl:param[@name = 'ws.op'])]" | ||
643 | 622 | mode="standard-method"> | ||
644 | 623 | <xsl:sort select="@name"/> | ||
645 | 624 | </xsl:apply-templates> | ||
646 | 625 | </dl> | ||
647 | 626 | </div> | ||
648 | 627 | </xsl:template> | ||
649 | 628 | |||
650 | 629 | <!-- Documentation for the standard GET on an entry --> | ||
651 | 630 | <xsl:template match="wadl:method[@name='GET']" mode="standard-method"> | ||
652 | 631 | <dt><xsl:value-of select="@name" /></dt> | ||
653 | 632 | <dd>Response contains the default | ||
654 | 633 | <xsl:call-template name="representation-type" /> representation | ||
655 | 634 | for this entry. | ||
656 | 635 | </dd> | ||
657 | 636 | </xsl:template> | ||
658 | 637 | |||
659 | 638 | <!-- Documentation for the standard PUT on an entry --> | ||
660 | 639 | <xsl:template match="wadl:method[@name='PUT']" mode="standard-method"> | ||
661 | 640 | <dt><xsl:value-of select="@name" /></dt> | ||
662 | 641 | <dd>Entity body should contain a representation encoded using | ||
663 | 642 | <xsl:call-template name="representation-type" /> of the entry. | ||
664 | 643 | All fields of the default representation should be included. Only | ||
665 | 644 | fields marked as writeable in the default representation should be | ||
666 | 645 | modified. | ||
667 | 646 | </dd> | ||
668 | 647 | </xsl:template> | ||
669 | 648 | |||
670 | 649 | <!-- Documentation for the standard PATCH on an entry --> | ||
671 | 650 | <xsl:template match="wadl:method[@name='PATCH']" mode="standard-method"> | ||
672 | 651 | <dt><xsl:value-of select="@name" /></dt> | ||
673 | 652 | <dd>Entity body should contain a represention encoded using | ||
674 | 653 | <xsl:call-template name="representation-type"/> of the entry | ||
675 | 654 | fields to update. Any fields of the default representation marked | ||
676 | 655 | as writeable can be included. | ||
677 | 656 | </dd> | ||
678 | 657 | </xsl:template> | ||
679 | 658 | |||
680 | 659 | <!-- Documentation for the custom GET operations of the resource type --> | ||
681 | 660 | <xsl:template name="custom-GETs"> | ||
682 | 661 | <xsl:variable name="operations" select="wadl:method[ | ||
683 | 662 | @name = 'GET'][.//wadl:param[@name = 'ws.op']]" /> | ||
684 | 663 | |||
685 | 664 | <xsl:if test="$operations"> | ||
686 | 665 | <div id="{@id}-custom-GETs" title="{@id}-custom-GETs" class="methods GETs"> | ||
687 | 666 | <h4>Custom GET methods</h4> | ||
688 | 667 | |||
689 | 668 | <xsl:apply-templates select="$operations"> | ||
690 | 669 | <xsl:sort select=".//wadl:param[@name='ws.op']/@fixed"/> | ||
691 | 670 | </xsl:apply-templates> | ||
692 | 671 | </div> | ||
693 | 672 | </xsl:if> | ||
694 | 673 | </xsl:template> | ||
695 | 674 | |||
696 | 675 | <!-- Documentation for the custom POST operations of the resource type --> | ||
697 | 676 | <xsl:template name="custom-POSTs"> | ||
698 | 677 | <xsl:variable name="operations" select="wadl:method[ | ||
699 | 678 | @name = 'POST'][.//wadl:param[@name = 'ws.op']]" /> | ||
700 | 679 | |||
701 | 680 | <xsl:if test="$operations"> | ||
702 | 681 | <div id="{@id}-custom-POSTs" title="{@id}-custom-POSTs" class="methods POSTs"> | ||
703 | 682 | <h4>Custom POST methods</h4> | ||
704 | 683 | |||
705 | 684 | <xsl:apply-templates select="$operations"> | ||
706 | 685 | <xsl:sort select=".//wadl:param[@name='ws.op']/@fixed"/> | ||
707 | 686 | </xsl:apply-templates> | ||
708 | 687 | </div> | ||
709 | 688 | </xsl:if> | ||
710 | 689 | </xsl:template> | ||
711 | 690 | |||
712 | 691 | <!-- Container for all the entry types documentation --> | ||
713 | 692 | <xsl:template name="entry-types"> | ||
714 | 693 | <h2 id="entry-types" title="entry-types">Entry types</h2> | ||
715 | 694 | |||
716 | 695 | <!-- Process all the resource_types, except the service-root ones, | ||
717 | 696 | the type describing collections of that type, | ||
718 | 697 | or any other ones, linked from within the service root. | ||
719 | 698 | --> | ||
720 | 699 | <xsl:for-each select="wadl:resource_type[ | ||
721 | 700 | @id != 'service-root' | ||
722 | 701 | and @id != 'HostedFile' | ||
723 | 702 | and not(contains(@id, 'page-resource')) | ||
724 | 703 | ]"> | ||
725 | 704 | <xsl:sort select="@id" /> | ||
726 | 705 | <xsl:variable name="id" select="./@id"/> | ||
727 | 706 | <xsl:variable name="top_level_collections" | ||
728 | 707 | select="key('id', 'service-root-json')//@resource_type[ | ||
729 | 708 | substring-after(., '#') = $id]" /> | ||
730 | 709 | <xsl:if test="not($top_level_collections[contains(., $id)])"> | ||
731 | 710 | <xsl:apply-templates select="." mode="entry-types" /> | ||
732 | 711 | </xsl:if> | ||
733 | 712 | </xsl:for-each> | ||
734 | 713 | </xsl:template> | ||
735 | 714 | |||
736 | 715 | <!-- Documentation for one entry-type --> | ||
737 | 716 | <xsl:template match="wadl:resource_type" mode="entry-types"> | ||
738 | 717 | <h3 id="{@id}" title="{@id}"><xsl:call-template name="get-title-or-id"/></h3> | ||
739 | 718 | <xsl:apply-templates select="wadl:doc"/> | ||
740 | 719 | |||
741 | 720 | <xsl:call-template name="entry-uri-doc"/> | ||
742 | 721 | |||
743 | 722 | <xsl:call-template name="default-representation" /> | ||
744 | 723 | <xsl:call-template name="standard-methods" /> | ||
745 | 724 | <xsl:call-template name="custom-GETs" /> | ||
746 | 725 | <xsl:call-template name="custom-POSTs" /> | ||
747 | 726 | <a href="#toc" class="toc-link">(back to Table of Contents)</a> | ||
748 | 727 | </xsl:template> | ||
749 | 728 | |||
750 | 729 | <!-- Documentation of the default representation for an entry --> | ||
751 | 730 | <xsl:template name="default-representation"> | ||
752 | 731 | <xsl:variable name="default_get" select="wadl:method[ | ||
753 | 732 | @name = 'GET' and not(wadl:request)]" /> | ||
754 | 733 | <xsl:variable name="representation" select="key( | ||
755 | 734 | 'id', substring-after( | ||
756 | 735 | $default_get/wadl:response/wadl:representation[ | ||
757 | 736 | not(@mediaType)]/@href, '#'))"/> | ||
758 | 737 | |||
759 | 738 | <div class="representation"> | ||
760 | 739 | <h4>Default representation | ||
761 | 740 | (<xsl:value-of select="$representation/@mediaType"/>)</h4> | ||
762 | 741 | |||
763 | 742 | <table> | ||
764 | 743 | <tr> | ||
765 | 744 | <th>Key</th> | ||
766 | 745 | <th>Value</th> | ||
767 | 746 | <th>Description</th> | ||
768 | 747 | </tr> | ||
769 | 748 | <xsl:apply-templates select="$representation/wadl:param" | ||
770 | 749 | mode="representation"> | ||
771 | 750 | <xsl:sort select="@name"/> | ||
772 | 751 | </xsl:apply-templates> | ||
773 | 752 | </table> | ||
774 | 753 | </div> | ||
775 | 754 | </xsl:template> | ||
776 | 755 | |||
777 | 756 | <!-- Output the cell containing the field name. | ||
778 | 757 | |||
779 | 758 | current() should be a wadl:param. | ||
780 | 759 | --> | ||
781 | 760 | <xsl:template name="param-name"> | ||
782 | 761 | <td> | ||
783 | 762 | <p><strong><xsl:value-of select="@name"/></strong></p> | ||
784 | 763 | </td> | ||
785 | 764 | </xsl:template> | ||
786 | 765 | |||
787 | 766 | <!-- Output a table cell containing the parameter description. | ||
788 | 767 | |||
789 | 768 | current() should a wadl:param. | ||
790 | 769 | --> | ||
791 | 770 | <xsl:template name="param-description"> | ||
792 | 771 | <td> | ||
793 | 772 | <xsl:apply-templates select="wadl:doc"/> | ||
794 | 773 | <xsl:if test="wadl:option[wadl:doc]"> | ||
795 | 774 | <dl> | ||
796 | 775 | <xsl:apply-templates | ||
797 | 776 | select="wadl:option" mode="option-doc"/> | ||
798 | 777 | </dl> | ||
799 | 778 | </xsl:if> | ||
800 | 779 | </td> | ||
801 | 780 | </xsl:template> | ||
802 | 781 | |||
803 | 782 | <!-- Output information about the parameter value. | ||
804 | 783 | |||
805 | 784 | current() should be a wadl:param. | ||
806 | 785 | --> | ||
807 | 786 | <xsl:template name="param-value"> | ||
808 | 787 | <xsl:if test="wadl:option"> | ||
809 | 788 | <p><em>One of:</em></p> | ||
810 | 789 | <ul> | ||
811 | 790 | <xsl:apply-templates select="wadl:option"/> | ||
812 | 791 | </ul> | ||
813 | 792 | </xsl:if> | ||
814 | 793 | <xsl:apply-templates select="wadl:link[@resource_type]"/> | ||
815 | 794 | <xsl:if test="@default"> | ||
816 | 795 | <p> | ||
817 | 796 | Default: | ||
818 | 797 | <var><xsl:value-of select="@default"/></var> | ||
819 | 798 | </p> | ||
820 | 799 | </xsl:if> | ||
821 | 800 | <xsl:if test="@fixed"> | ||
822 | 801 | <p> | ||
823 | 802 | Fixed: | ||
824 | 803 | <var><xsl:value-of select="@fixed"/></var> | ||
825 | 804 | </p> | ||
826 | 805 | </xsl:if> | ||
827 | 806 | </xsl:template> | ||
828 | 807 | |||
829 | 808 | <!-- Output row describing one field in the default representation --> | ||
830 | 809 | <xsl:template match="wadl:param" mode="representation"> | ||
831 | 810 | <xsl:variable name="resource_type" | ||
832 | 811 | select="substring-before(../@id, '-')" /> | ||
833 | 812 | <xsl:variable name="patch_representation_id" | ||
834 | 813 | ><xsl:value-of select="$resource_type"/>-diff</xsl:variable> | ||
835 | 814 | <xsl:variable name="patch_representation" | ||
836 | 815 | select="key('id', $patch_representation_id)"/> | ||
837 | 816 | <tr> | ||
838 | 817 | <xsl:call-template name="param-name"/> | ||
839 | 818 | <td> | ||
840 | 819 | <p> | ||
841 | 820 | <xsl:choose> | ||
842 | 821 | <xsl:when test="$patch_representation/wadl:param[@name | ||
843 | 822 | = current()/@name]"> | ||
844 | 823 | <small>(writeable)</small> | ||
845 | 824 | </xsl:when> | ||
846 | 825 | <xsl:otherwise> | ||
847 | 826 | <small>(read-only)</small> | ||
848 | 827 | </xsl:otherwise> | ||
849 | 828 | </xsl:choose> | ||
850 | 829 | </p> | ||
851 | 830 | <xsl:call-template name="param-value" /> | ||
852 | 831 | </td> | ||
853 | 832 | <xsl:call-template name="param-description" /> | ||
854 | 833 | </tr> | ||
855 | 834 | </xsl:template> | ||
856 | 835 | |||
857 | 836 | <!-- Output the description of a link type in param listing --> | ||
858 | 837 | <xsl:template match="wadl:link[ | ||
859 | 838 | @resource_type and ../@name != 'self_link']"> | ||
860 | 839 | <xsl:variable name="resource_type" | ||
861 | 840 | select="substring-after(@resource_type, '#')"/> | ||
862 | 841 | <xsl:choose> | ||
863 | 842 | <xsl:when test="contains($resource_type, 'page-resource')"> | ||
864 | 843 | Link to a <a href="#{substring-before($resource_type, '-')}" | ||
865 | 844 | ><xsl:value-of | ||
866 | 845 | select="substring-before($resource_type, '-')" | ||
867 | 846 | /></a> collection. | ||
868 | 847 | </xsl:when> | ||
869 | 848 | <xsl:when test="$resource_type = 'HostedFile'"> | ||
870 | 849 | Link to a file resource. | ||
871 | 850 | </xsl:when> | ||
872 | 851 | <xsl:otherwise> | ||
873 | 852 | Link to a <a href="#{$resource_type}" | ||
874 | 853 | ><xsl:value-of select="$resource_type"/></a>. | ||
875 | 854 | </xsl:otherwise> | ||
876 | 855 | </xsl:choose> | ||
877 | 856 | </xsl:template> | ||
878 | 857 | |||
879 | 858 | <!-- Documentation for a custom method --> | ||
880 | 859 | <xsl:template match="wadl:method[.//wadl:param[@name = 'ws.op']]"> | ||
881 | 860 | <div class="method"> | ||
882 | 861 | <h5 id="{@id}" title="{@id}"><xsl:value-of | ||
883 | 862 | select=".//wadl:param[@name = 'ws.op']/@fixed"/></h5> | ||
884 | 863 | <xsl:choose> | ||
885 | 864 | <xsl:when test="wadl:doc|wadl:request|wadl:response"> | ||
886 | 865 | <xsl:apply-templates select="wadl:doc"/> | ||
887 | 866 | <xsl:apply-templates select="wadl:request"/> | ||
888 | 867 | <xsl:apply-templates select="wadl:response"/> | ||
889 | 868 | </xsl:when> | ||
890 | 869 | <xsl:otherwise> | ||
891 | 870 | <p><em>Missing documentation.</em></p> | ||
892 | 871 | </xsl:otherwise> | ||
893 | 872 | </xsl:choose> | ||
894 | 873 | </div> | ||
895 | 874 | </xsl:template> | ||
896 | 875 | |||
897 | 876 | <!-- Documentation for the request parameters of a custom method --> | ||
898 | 877 | <xsl:template match="wadl:request"> | ||
899 | 878 | <h6>Parameters</h6> | ||
900 | 879 | <table> | ||
901 | 880 | <tr> | ||
902 | 881 | <th>Parameter</th> | ||
903 | 882 | <th>Value</th> | ||
904 | 883 | <th>Description</th> | ||
905 | 884 | </tr> | ||
906 | 885 | <xsl:apply-templates | ||
907 | 886 | select=".//wadl:param[@style='query'][@fixed]"/> | ||
908 | 887 | <xsl:apply-templates | ||
909 | 888 | select=".//wadl:param[@style='query'][not(@fixed)]"> | ||
910 | 889 | <xsl:sort select="@name" /> | ||
911 | 890 | </xsl:apply-templates> | ||
912 | 891 | </table> | ||
913 | 892 | </xsl:template> | ||
914 | 893 | |||
915 | 894 | <!-- Documentation for the response of custom methods returning | ||
916 | 895 | and entry or a collection. | ||
917 | 896 | --> | ||
918 | 897 | <xsl:template match="wadl:response/wadl:representation[@href]"> | ||
919 | 898 | <xsl:variable name="id" select="substring-after(@href, '#')" /> | ||
920 | 899 | <xsl:variable name="resource_type" | ||
921 | 900 | select="substring-before($id, '-')"/> | ||
922 | 901 | |||
923 | 902 | <p class="response">Response contains an | ||
924 | 903 | <xsl:apply-templates select="key('id', $id)" | ||
925 | 904 | mode="representation-type"/> | ||
926 | 905 | representation of a | ||
927 | 906 | <a href="#{$resource_type}"><xsl:value-of | ||
928 | 907 | select="$resource_type" | ||
929 | 908 | /></a><xsl:if test="contains($id, '-page')"> | ||
930 | 909 | collection | ||
931 | 910 | </xsl:if>. | ||
932 | 911 | </p> | ||
933 | 912 | </xsl:template> | ||
934 | 913 | |||
935 | 914 | <!-- Documentation for request parameter. --> | ||
936 | 915 | <xsl:template match="wadl:param"> | ||
937 | 916 | <tr> | ||
938 | 917 | <xsl:call-template name="param-name"/> | ||
939 | 918 | <td> | ||
940 | 919 | <xsl:if test="@required or @repeating"> | ||
941 | 920 | <p> | ||
942 | 921 | <xsl:if test="@required='true'"> | ||
943 | 922 | <small>(required)</small> | ||
944 | 923 | </xsl:if> | ||
945 | 924 | <xsl:if test="@repeating='true'"> | ||
946 | 925 | <small>(repeating)</small> | ||
947 | 926 | </xsl:if> | ||
948 | 927 | </p> | ||
949 | 928 | </xsl:if> | ||
950 | 929 | <xsl:call-template name="param-value"/> | ||
951 | 930 | </td> | ||
952 | 931 | <xsl:call-template name="param-description"/> | ||
953 | 932 | </tr> | ||
954 | 933 | </xsl:template> | ||
955 | 934 | |||
956 | 935 | <!-- Documentation for factories. | ||
957 | 936 | |||
958 | 937 | Factory's response include a Location header pointint to a resource type. | ||
959 | 938 | --> | ||
960 | 939 | <xsl:template match="wadl:response/wadl:param[ | ||
961 | 940 | @name = 'Location' and @style = 'header' | ||
962 | 941 | and wadl:link[@resource_type]]"> | ||
963 | 942 | <xsl:variable name="resource_type" | ||
964 | 943 | select="substring-after( | ||
965 | 944 | wadl:link[@resource_type]/@resource_type, '#')"/> | ||
966 | 945 | <p>On success, the response status will be 201 and the | ||
967 | 946 | <var>Location</var> header will contain the link to the newly | ||
968 | 947 | created <a href="#{$resource_type}" | ||
969 | 948 | ><xsl:value-of select="$resource_type" /></a>. | ||
970 | 949 | </p> | ||
971 | 950 | </xsl:template> | ||
972 | 951 | |||
973 | 952 | <!-- Output the available value for the parameter. --> | ||
974 | 953 | <xsl:template match="wadl:option"> | ||
975 | 954 | <li> | ||
976 | 955 | <tt><xsl:value-of select="@value"/></tt> | ||
977 | 956 | <xsl:if test="ancestor::wadl:param[1]/@default=@value"> | ||
978 | 957 | <small>(default)</small> | ||
979 | 958 | </xsl:if> | ||
980 | 959 | </li> | ||
981 | 960 | </xsl:template> | ||
982 | 961 | |||
983 | 962 | <!-- Ouput list of the documentation for each available option. --> | ||
984 | 963 | <xsl:template match="wadl:option" mode="option-doc"> | ||
985 | 964 | <dt> | ||
986 | 965 | <tt><xsl:value-of select="@value"/></tt> | ||
987 | 966 | <xsl:if test="ancestor::wadl:param[1]/@default=@value"> | ||
988 | 967 | <small>(default)</small> | ||
989 | 968 | </xsl:if> | ||
990 | 969 | </dt> | ||
991 | 970 | <dd> | ||
992 | 971 | <xsl:apply-templates select="wadl:doc"/> | ||
993 | 972 | </dd> | ||
994 | 973 | </xsl:template> | ||
995 | 974 | |||
996 | 975 | <!-- Format wadl:doc --> | ||
997 | 976 | <xsl:template match="wadl:doc"> | ||
998 | 977 | <xsl:param name="inline">0</xsl:param> | ||
999 | 978 | <!-- skip WADL elements --> | ||
1000 | 979 | <xsl:choose> | ||
1001 | 980 | <xsl:when test="node()[1]=text() and $inline=0"> | ||
1002 | 981 | <!-- If the wadl:doc contains <p> tags wrap it in a <div>, | ||
1003 | 982 | otherwise wrap it in a <p> tag. --> | ||
1004 | 983 | <xsl:choose> | ||
1005 | 984 | <xsl:when test="./html:p"> | ||
1006 | 985 | <div> | ||
1007 | 986 | <xsl:apply-templates select="node()" mode="copy"/> | ||
1008 | 987 | </div> | ||
1009 | 988 | </xsl:when> | ||
1010 | 989 | <xsl:otherwise> | ||
1011 | 990 | <p> | ||
1012 | 991 | <xsl:apply-templates select="node()" mode="copy"/> | ||
1013 | 992 | </p> | ||
1014 | 993 | </xsl:otherwise> | ||
1015 | 994 | </xsl:choose> | ||
1016 | 995 | </xsl:when> | ||
1017 | 996 | <xsl:otherwise> | ||
1018 | 997 | <xsl:apply-templates select="node()" mode="copy"/> | ||
1019 | 998 | </xsl:otherwise> | ||
1020 | 999 | </xsl:choose> | ||
1021 | 1000 | </xsl:template> | ||
1022 | 1001 | |||
1023 | 1002 | <!-- Returns the title or id of an element. | ||
1024 | 1003 | |||
1025 | 1004 | Look for the first wadl:doc title attribute content of the | ||
1026 | 1005 | current node or fall back to the element id. | ||
1027 | 1006 | |||
1028 | 1007 | :param element: The element to return the title or id. Defaults to the | ||
1029 | 1008 | current node. | ||
1030 | 1009 | --> | ||
1031 | 1010 | <xsl:template name="get-title-or-id"> | ||
1032 | 1011 | <xsl:param name="element" select="current()" /> | ||
1033 | 1012 | <xsl:choose> | ||
1034 | 1013 | <xsl:when test="$element/wadl:doc[@title]"> | ||
1035 | 1014 | <xsl:value-of select="$element/wadl:doc[@title][1]/@title"/> | ||
1036 | 1015 | </xsl:when> | ||
1037 | 1016 | <xsl:otherwise> | ||
1038 | 1017 | <xsl:value-of select="$element/@id"/> | ||
1039 | 1018 | </xsl:otherwise> | ||
1040 | 1019 | </xsl:choose> | ||
1041 | 1020 | </xsl:template> | ||
1042 | 1021 | |||
1043 | 1022 | <!-- Output the mediaType attribute of the default representation. | ||
1044 | 1023 | |||
1045 | 1024 | Should be call on an element that contain a wadl:representation element | ||
1046 | 1025 | without a mediaType attribute. | ||
1047 | 1026 | --> | ||
1048 | 1027 | <xsl:template name="representation-type"> | ||
1049 | 1028 | <xsl:apply-templates | ||
1050 | 1029 | select="key('id', | ||
1051 | 1030 | substring-after( | ||
1052 | 1031 | .//wadl:representation[not(@mediaType)]/@href, | ||
1053 | 1032 | '#'))" | ||
1054 | 1033 | mode="representation-type"/> | ||
1055 | 1034 | </xsl:template> | ||
1056 | 1035 | |||
1057 | 1036 | <!-- Omit docutils parameter lists in methods since they are redundant | ||
1058 | 1037 | or misleading with the one we give. --> | ||
1059 | 1038 | <xsl:template match="wadl:method//html:table[ | ||
1060 | 1039 | contains(@class, 'field-list')]" | ||
1061 | 1040 | mode="copy"/> | ||
1062 | 1041 | |||
1063 | 1042 | <!-- Output the mediaType attribute of a representation --> | ||
1064 | 1043 | <xsl:template match="wadl:representation[@mediaType]" | ||
1065 | 1044 | mode="representation-type"> | ||
1066 | 1045 | <code><xsl:value-of select="@mediaType"/></code> | ||
1067 | 1046 | </xsl:template> | ||
1068 | 1047 | |||
1069 | 1048 | <!-- Copy html elements. --> | ||
1070 | 1049 | <xsl:template match="html:*" mode="copy"> | ||
1071 | 1050 | <!-- remove the prefix on HTML elements --> | ||
1072 | 1051 | <xsl:element name="{local-name()}"> | ||
1073 | 1052 | <xsl:for-each select="@*"> | ||
1074 | 1053 | <xsl:attribute name="{local-name()}" | ||
1075 | 1054 | ><xsl:value-of select="."/></xsl:attribute> | ||
1076 | 1055 | </xsl:for-each> | ||
1077 | 1056 | <xsl:apply-templates select="node()" mode="copy"/> | ||
1078 | 1057 | </xsl:element> | ||
1079 | 1058 | </xsl:template> | ||
1080 | 1059 | |||
1081 | 1060 | <xsl:template match="@*|node()[ | ||
1082 | 1061 | namespace-uri()!='http://www.w3.org/1999/xhtml']" mode="copy"> | ||
1083 | 1062 | <!-- everything else goes straight through --> | ||
1084 | 1063 | <xsl:copy> | ||
1085 | 1064 | <xsl:apply-templates select="@*|node()" mode="copy"/> | ||
1086 | 1065 | </xsl:copy> | ||
1087 | 1066 | </xsl:template> | ||
1088 | 1067 | |||
1089 | 1068 | </xsl:stylesheet> |
This looks fine.