]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/docgen.xsl
fixups, and starting a paged interface
[Evergreen.git] / Open-ILS / src / extras / docgen.xsl
1 <?xml-stylesheet type="text/xsl"  href="#"?> 
2 <xsl:stylesheet
3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4   xmlns:res="http://example.com/test"
5   version="1.0"
6   >
7   <xsl:template match="xsl:stylesheet">
8     <html>
9       <head>
10         <style type="text/css">
11 body { background-color:#F0F0F0; font: 9pt Verdana, Arial, "Arial Unicode MS", Helvetica, sans-serif;}
12 input.button { font:8pt Verdana, Arail, "Arial Unicode MS", Helvetica, sans-serif;}
13 input.text {}
14 div.DDB { position:absolute; top:20pt; left:15pt; visibility:visible; }
15 div.DLC { position:absolute; top:20pt; left:15pt; visibility:hidden; }
16 div.numFound { position:absolute; top:0px; left:0pt; font-weight:bold;}
17
18 table { background-color:lightgray; font-size:10pt; margin:10pt 0pt 15pt 0pt; width:90%; border-collapse: collapse; spacing:0; padding:0;}
19 td { background-color:#f0f0f0; border: solid lightgray 1px; }
20 td.fulltag { background-color:#f0f0f0;}
21 td.fullind { background-color:#f0f0f0;  width:20pt;}
22 td.fullfield{ background-color:#f0f0f0; width:100%;}
23
24 table.signature { background-color:lightgray; font-size:10pt; margin:0; width:100%; border:none; padding:0;}
25 table.params { background-color:lightgray; font-size:10pt; margin:3px 0px 3px 0px; width:100%; border: solid black 1px; padding:0;}
26 td.params { background-color:lightgray; font-size:10pt; border: solid black 1px;}
27
28 h1 { text-decoration: underline; }
29
30 td.header { font-weight:bold; color:black; font-size:14pt; border-bottom: solid gray 2px}
31 td.label { vertical-align:top; padding-left:10pt; width:120pt; font-weight:normal; color:darkblue;}
32 td.value { vertical-align:top; text-align:left; font-weight: bold;}
33 span.subcode { color:darkblue;}        </style>
34
35       </head>
36       <body>
37         <a name="top"/>
38
39 <!--#if expr='"$QUERY_STRING" = /limit=([^&]+)/' -->
40   <!--#set var="limit" value="$1" -->
41 <!--#else -->
42   <!--#set var="limit" value="10" -->
43 <!--#endif -->
44
45 <!--#if expr='"$QUERY_STRING" = /offset=([^&]+)/' -->
46   <!--#set var="offset" value="$1" -->
47 <!--#else -->
48   <!--#set var="offset" value="0" -->
49 <!--#endif -->
50
51 <!--#if expr='"$QUERY_STRING" = /service=([^&]+)/' -->
52   <!--#set var="service" value="$1" -->
53 <!--#else -->
54   <!--#set var="service" value="" -->
55 <!--#endif -->
56
57 <!--#if expr='"$QUERY_STRING" = /method=([^&]+)/' -->
58   <!--#set var="method" value="$1" -->
59 <!--#endif -->
60
61 <!--#if expr="$QUERY_STRING = /all=on/" -->
62   <!--#set var="all" value="true" -->
63 <!--#else -->
64   <!--#set var="all" value="false" -->
65 <!--#endif -->
66
67 <!--#if expr="$QUERY_STRING = /param=%22([^&]+)%22/" -->
68   <!--#set var="param" value="$1" -->
69 <!--#else -->
70   <!--#set var="param" value="" -->
71 <!--#endif -->
72
73         <xsl:if test="not(res:content/res:response)">
74           <br/><br/><br/><br/><br/><br/>
75           <br/><br/><br/><br/><br/><br/>
76         </xsl:if>
77
78         <form
79           method="GET"
80           action='<!--#echo var="DOCUMENT_URI" -->'
81           onsubmit='
82             this.param.value = "\"" + this.param.value + "\"";
83             if (this.all.checked) this.method.value = "opensrf.system.method.all";
84           '>
85           <xsl:if test="not(res:content/res:response)">
86             <xsl:attribute name="style">
87               <xsl:value-of select="'text-align:center;'"/>
88             </xsl:attribute>
89           </xsl:if>
90           Application:
91           <input name="service" type="text" value='<!--#echo var="service" -->'/>&#160;
92           API Method Name Regex:
93           <input name="param" type="text" value='<!--#echo var="param" -->'>
94             <xsl:if test="'<!--#echo var="all" -->' = 'true'">
95               <xsl:attribute name="disabled">
96                 <xsl:value-of select="'true'"/>
97               </xsl:attribute>
98             </xsl:if>
99           </input>&#160;
100           All Methods (Use with care!)
101           <input
102             name="all"
103             type="checkbox"
104             value="on"
105             onclick='
106               if (this.checked) this.form.param.disabled = true;
107               else this.form.param.disabled = false;
108             '>
109             <xsl:if test="'<!--#echo var="all" -->' = 'true'">
110               <xsl:attribute name="checked">
111                 <xsl:value-of select="'checked'"/>
112               </xsl:attribute>
113             </xsl:if>
114
115             </input>&#160;
116           <button name="method" value="opensrf.system.method">Find 'em</button>
117         </form>
118
119         <xsl:if test="res:content/res:response">
120           <hr/>
121
122           <xsl:apply-templates select="res:content/res:response"/>
123
124           <hr/>
125
126           <form
127             method="GET"
128             action='<!--#echo var="DOCUMENT_URI" -->'
129             onsubmit='
130               this.param.value = "\"" + this.param.value + "\"";
131               if (this.all.checked) this.method.value = "opensrf.system.method.all";
132             '>
133             <xsl:if test="not(res:content/res:response)">
134               <xsl:attribute name="style">
135                 <xsl:value-of select="'text-align:center;'"/>
136               </xsl:attribute>
137             </xsl:if>
138             Application:
139             <input name="service" type="text" value='<!--#echo var="service" -->'/>&#160;
140             API Method Name Regex:
141             <input name="param" type="text" value='<!--#echo var="param" -->'>
142               <xsl:if test="'<!--#echo var="all" -->' = 'true'">
143                 <xsl:attribute name="disabled">
144                   <xsl:value-of select="'true'"/>
145                 </xsl:attribute>
146               </xsl:if>
147             </input>&#160;
148             All Methods (Use with care!)
149             <input
150               name="all"
151               type="checkbox"
152               value="on"
153               onclick='
154                 if (this.checked) this.form.param.disabled = true;
155                 else this.form.param.disabled = false;
156               '>
157               <xsl:if test="'<!--#echo var="all" -->' = 'true'">
158                 <xsl:attribute name="checked">
159                   <xsl:value-of select="'checked'"/>
160                 </xsl:attribute>
161               </xsl:if>
162   
163               </input>&#160;
164             <button name="method" value="opensrf.system.method">Find 'em</button>
165           </form>
166
167         </xsl:if>
168       </body>
169     </html>
170   </xsl:template>
171
172   <xsl:template match="res:api_name">
173     API Level: <xsl:value-of select="../res:api_level/text()"/> / Method: 
174     <a>
175       <xsl:attribute name="href">#<xsl:value-of select="./text()"/></xsl:attribute>
176       <xsl:value-of select="./text()"/>
177     </a>
178     <br/>
179   </xsl:template>
180
181   <xsl:template match="res:response">
182     <xsl:choose>
183       <xsl:when test="count(//res:api_name) > 1">
184         <h1>Matching Methods</h1>
185         <xsl:apply-templates select="//res:api_name">
186           <xsl:sort select="text()"/>
187         </xsl:apply-templates>
188
189         <h1>Method Definitions</h1>
190       </xsl:when>
191       <xsl:when test="count(//res:api_name) = 0">
192         <h1><i>No Matching Methods Found</i></h1>
193       </xsl:when>
194     </xsl:choose>
195
196     <xsl:apply-templates select="res:hash/res:pair[res:key/text()='payload']/res:value/res:array/res:datum/res:Object">
197       <xsl:sort select="res:api_name/text()"/>
198     </xsl:apply-templates>
199   </xsl:template>
200
201
202   <xsl:template match="res:Object">
203     <xsl:if test="res:remote/text()='0'">
204
205       <xsl:if test="count(//res:api_name) > 1">
206         <a>
207           <xsl:attribute name="name"><xsl:value-of select="res:api_name/text()"/></xsl:attribute>
208         </a>
209         <a href="#top">Top</a>
210       </xsl:if>
211
212       <table>
213         <tr>
214           <td colspan="3" class="header"><xsl:value-of select="res:api_name"/></td>
215         </tr>
216         <tr>
217           <td class="label">API Level:</td>
218           <td colspan="2" class="value"><xsl:value-of select="res:api_level"/></td>
219         </tr>
220         <tr>
221           <td class="label">Package:</td>
222           <td colspan="2" class="value"><xsl:value-of select="res:package"/></td>
223         </tr>
224         <tr>
225           <td class="label">Required argument count:</td>
226           <td colspan="2" class="value"><xsl:value-of select="res:argc"/></td>
227         </tr>
228         <xsl:if test="normalize-space(res:signature/res:desc/text()) != normalize-space(res:notes/text())">
229           <tr>
230             <td class="label">
231               <xsl:attribute name='rowspan'>
232                 <xsl:value-of select='count(res:signature/res:params/res:hash) + 6'/>
233               </xsl:attribute>
234               Signature:
235             </td>
236           </tr>
237           <xsl:apply-templates select="res:signature"/>
238         </xsl:if>
239         <tr>
240           <td class="label">Streaming method:</td>
241           <td colspan="2" class="value">
242             <xsl:if test="res:stream/text()='1'">Yes</xsl:if>
243             <xsl:if test="res:stream/text()='0'">No</xsl:if>
244           </td>
245         </tr>
246         <xsl:if test="res:notes">
247           <tr>
248             <td class="label">Notes:</td>
249             <td colspan="2" class="value"><pre style="font-weight:normal;font-size:10px;"><xsl:value-of select="res:notes"/></pre></td>
250           </tr>
251         </xsl:if>
252       </table>
253     </xsl:if>
254   </xsl:template>
255
256
257   <xsl:template match="res:pair">
258     <tr>
259       <td class="label params">
260         <xsl:if test="res:key/text()='name'">Name:</xsl:if>
261         <xsl:if test="res:key/text()='desc'">Description:</xsl:if>
262         <xsl:if test="res:key/text()='type'">Data type:</xsl:if>
263         <xsl:if test="res:key/text()='class'">Object class:</xsl:if>
264       </td>
265       <td class="value params"><xsl:value-of select="res:value"/></td>
266     </tr>
267   </xsl:template>
268
269
270   <xsl:template match="res:hash">
271     <tr>
272       <td>
273         <table class="params">
274           <tr>
275             <td class="label params">Position:</td>
276             <td class="value params"><xsl:value-of select="position()"/></td>
277           </tr>
278           <xsl:apply-templates select="res:pair[res:key/text()='name']"/>
279           <xsl:apply-templates select="res:pair[res:key/text()='desc']"/>
280           <xsl:apply-templates select="res:pair[res:key/text()='type']"/>
281           <xsl:apply-templates select="res:pair[res:key/text()='class']"/>
282         </table>
283       </td>
284     </tr>
285   </xsl:template>
286
287
288   <xsl:template match="res:signature">
289       <xsl:if test="res:desc">
290         <tr>
291           <td class="label">Description:</td>
292           <td class="value"><xsl:value-of select="res:desc"/></td>
293         </tr>
294       </xsl:if>
295       <xsl:if test="res:params/res:hash">
296         <tr>
297           <td class="label">
298             <xsl:attribute name='rowspan'>
299               <xsl:value-of select='count(res:params/res:hash) + 1'/>
300             </xsl:attribute>
301             Parameters:</td>
302         </tr>
303       </xsl:if>
304       <xsl:apply-templates select="res:params/res:hash">
305         <xsl:sort select="position()"/>
306       </xsl:apply-templates>
307       <xsl:if test="res:return">
308         <tr>
309           <td class="label">Returns:</td>
310           <td class="value"><xsl:value-of select="res:return/res:desc"/></td>
311         </tr>
312         <tr>
313           <td class="label">Return type:</td>
314           <td class="value"><xsl:value-of select="res:return/res:type"/></td>
315         </tr>
316         <tr>
317           <td class="label">Return type class:</td>
318           <td class="value"><xsl:value-of select="res:return/res:class"/></td>
319         </tr>
320       </xsl:if>
321   </xsl:template>
322
323
324   <!--#if expr="$QUERY_STRING = /service=[^&]+/" -->
325     <!--#if expr="$QUERY_STRING = /param=%22[^&]+%22/" -->
326       <content xmlns="http://example.com/test">
327         <!--#include virtual="/restgateway?${QUERY_STRING}"-->
328         <!-- virtual='/restgateway?service=$service&method=$method&param="$param"&param=$limit&param=$offset'-->
329       </content>
330     <!--#endif -->
331     <!--#if expr="$QUERY_STRING = /all=on/" -->
332       <content xmlns="http://example.com/test">
333         <!--#include virtual="/restgateway?${QUERY_STRING}"-->
334         <!-- virtual='/restgateway?service=$service&method=$method&param=""&param=$limit&param=$offset' -->
335       </content>
336     <!--#endif -->
337   <!--#endif -->
338
339
340 </xsl:stylesheet>
341