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

Subscribers

People subscribed via source and target branches