Merge lp:~leonardr/launchpadlib/remove-xslt into lp:launchpadlib

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
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

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
j.c.sackett (jcsackett) wrote :

This looks fine.

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

Subscribers

People subscribed via source and target branches