]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/extras/docgen.xsl
added an "all methods" option -- USE WITH CARE!!!
[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" = /service=([^&]+)/' -->
40   <!--#set var="service" value="$1" -->
41 <!--#endif -->
42
43 <!--#if expr="$QUERY_STRING = /all=on/" -->
44   <!--#set var="all" value="true" -->
45 <!--#else -->
46   <!--#set var="all" value="false" -->
47 <!--#endif -->
48
49 <!--#if expr="$QUERY_STRING = /param=%22([^&]+)%22/" -->
50   <!--#set var="param" value="$1" -->
51 <!--#endif -->
52
53         <xsl:if test="not(res:content)">
54           <br/><br/><br/><br/><br/><br/>
55           <br/><br/><br/><br/><br/><br/>
56         </xsl:if>
57
58         <form
59           method="GET"
60           action='<!--#echo var="DOCUMENT_URI" -->'
61           onsubmit='
62             this.param.value = "\"" + this.param.value + "\"";
63             if (this.all.checked) this.method.value = "opensrf.system.method.all";
64           '>
65           <xsl:if test="not(res:content)">
66             <xsl:attribute name="style">
67               <xsl:value-of select="'text-align:center;'"/>
68             </xsl:attribute>
69           </xsl:if>
70           Application:
71           <input name="service" type="text" value='<!--#echo var="service" -->'>
72             <xsl:if test="not(res:content)">
73               <xsl:attribute name="value">
74                 <xsl:value-of select="''"/>
75               </xsl:attribute>
76             </xsl:if>
77           </input>&#160;
78           API Method Name Regex:
79           <input name="param" type="text" value='<!--#echo var="param" -->'>
80             <xsl:if test="'<!--#echo var="all" -->' = 'true'">
81               <xsl:attribute name="disabled">
82                 <xsl:value-of select="'true'"/>
83               </xsl:attribute>
84             </xsl:if>
85             <xsl:if test="'<!--#echo var="param" -->' = '(none)'">
86               <xsl:attribute name="value">
87                 <xsl:value-of select="''"/>
88               </xsl:attribute>
89             </xsl:if>
90           </input>&#160;
91           All Methods
92           <input
93             name="all"
94             type="checkbox"
95             value="on"
96             onclick='
97               if (this.checked) this.form.param.disabled = true;
98               else this.form.param.disabled = false;
99             '>
100             <xsl:if test="'<!--#echo var="all" -->' = 'true'">
101               <xsl:attribute name="checked">
102                 <xsl:value-of select="'checked'"/>
103               </xsl:attribute>
104             </xsl:if>
105
106             </input>&#160;
107           <button name="method" value="opensrf.system.method">Find 'em</button>
108         </form>
109
110         <xsl:if test="res:content">
111           <hr/>
112
113           <xsl:apply-templates select="res:content/res:response"/>
114
115           <hr/>
116
117           <form
118             method="GET"
119             action='<!--#echo var="DOCUMENT_URI" -->'
120             onsubmit='
121               this.param.value = "\"" + this.param.value + "\"";
122               if (this.all.checked) this.method.value = "opensrf.system.method.all";
123             '>
124             <xsl:if test="not(res:content)">
125               <xsl:attribute name="style">
126                 <xsl:value-of select="'text-align:center;'"/>
127               </xsl:attribute>
128             </xsl:if>
129             Application:
130             <input name="service" type="text" value='<!--#echo var="service" -->'>
131               <xsl:if test="not(res:content)">
132                 <xsl:attribute name="value">
133                   <xsl:value-of select="''"/>
134                 </xsl:attribute>
135               </xsl:if>
136             </input>&#160;
137             API Method Name Regex:
138             <input name="param" type="text" value='<!--#echo var="param" -->'>
139               <xsl:if test="'<!--#echo var="all" -->' = 'true'">
140                 <xsl:attribute name="disabled">
141                   <xsl:value-of select="'true'"/>
142                 </xsl:attribute>
143               </xsl:if>
144               <xsl:if test="'<!--#echo var="param" -->' = '(none)'">
145                 <xsl:attribute name="value">
146                   <xsl:value-of select="''"/>
147                 </xsl:attribute>
148               </xsl:if>
149             </input>&#160;
150             All Methods
151             <input
152               name="all"
153               type="checkbox"
154               value="on"
155               onclick='
156                 if (this.checked) this.form.param.disabled = true;
157                 else this.form.param.disabled = false;
158               '>
159               <xsl:if test="'<!--#echo var="all" -->' = 'true'">
160                 <xsl:attribute name="checked">
161                   <xsl:value-of select="'checked'"/>
162                 </xsl:attribute>
163               </xsl:if>
164   
165               </input>&#160;
166             <button name="method" value="opensrf.system.method">Find 'em</button>
167           </form>
168
169         </xsl:if>
170       </body>
171     </html>
172   </xsl:template>
173
174   <xsl:template match="res:api_name">
175     <a>
176       <xsl:attribute name="href">#<xsl:value-of select="./text()"/></xsl:attribute>
177       <xsl:value-of select="./text()"/>
178     </a>
179     <br/>
180   </xsl:template>
181
182   <xsl:template match="res:response">
183     <xsl:if test="count(//res:api_name) > 1">
184       <h1>Method Index</h1>
185       <xsl:apply-templates select="//res:api_name"/>
186
187       <h1>Method Definitions</h1>
188     </xsl:if>
189
190     <xsl:apply-templates select="res:hash/res:pair[res:key/text()='payload']/res:value/res:array/res:datum/res:Object"/>
191   </xsl:template>
192
193
194   <xsl:template match="res:Object">
195     <xsl:if test="res:remote/text()='0'">
196
197       <xsl:if test="count(//res:api_name) > 1">
198         <a>
199           <xsl:attribute name="name"><xsl:value-of select="res:api_name/text()"/></xsl:attribute>
200         </a>
201         <a href="#top">Top</a>
202       </xsl:if>
203
204       <table>
205         <tr>
206           <td colspan="3" class="header"><xsl:value-of select="res:api_name"/></td>
207         </tr>
208         <tr>
209           <td class="label">API Level:</td>
210           <td colspan="2" class="value"><xsl:value-of select="res:api_level"/></td>
211         </tr>
212         <tr>
213           <td class="label">Package:</td>
214           <td colspan="2" class="value"><xsl:value-of select="res:package"/></td>
215         </tr>
216         <tr>
217           <td class="label">Required argument count:</td>
218           <td colspan="2" class="value"><xsl:value-of select="res:argc"/></td>
219         </tr>
220         <xsl:if test="normalize-space(res:signature/res:desc/text()) != normalize-space(res:notes/text())">
221           <tr>
222             <td class="label">
223               <xsl:attribute name='rowspan'>
224                 <xsl:value-of select='count(res:signature/res:params/res:hash) + 6'/>
225               </xsl:attribute>
226               Signature:
227             </td>
228           </tr>
229           <xsl:apply-templates select="res:signature"/>
230         </xsl:if>
231         <tr>
232           <td class="label">Streaming method:</td>
233           <td colspan="2" class="value">
234             <xsl:if test="res:stream/text()='1'">Yes</xsl:if>
235             <xsl:if test="res:stream/text()='0'">No</xsl:if>
236           </td>
237         </tr>
238         <xsl:if test="res:notes">
239           <tr>
240             <td class="label">Notes:</td>
241             <td colspan="2" class="value"><pre style="font-weight:normal;font-size:10px;"><xsl:value-of select="res:notes"/></pre></td>
242           </tr>
243         </xsl:if>
244       </table>
245     </xsl:if>
246   </xsl:template>
247
248
249   <xsl:template match="res:pair">
250     <tr>
251       <td class="label params">
252         <xsl:if test="res:key/text()='name'">Name:</xsl:if>
253         <xsl:if test="res:key/text()='desc'">Description:</xsl:if>
254         <xsl:if test="res:key/text()='type'">Data type:</xsl:if>
255         <xsl:if test="res:key/text()='class'">Object class:</xsl:if>
256       </td>
257       <td class="value params"><xsl:value-of select="res:value"/></td>
258     </tr>
259   </xsl:template>
260
261
262   <xsl:template match="res:hash">
263     <tr>
264       <td>
265         <table class="params">
266           <xsl:apply-templates select="res:pair[res:key/text()='name']"/>
267           <xsl:apply-templates select="res:pair[res:key/text()='desc']"/>
268           <xsl:apply-templates select="res:pair[res:key/text()='type']"/>
269           <xsl:apply-templates select="res:pair[res:key/text()='class']"/>
270         </table>
271       </td>
272     </tr>
273   </xsl:template>
274
275
276   <xsl:template match="res:signature">
277       <xsl:if test="res:desc">
278         <tr>
279           <td class="label">Description:</td>
280           <td class="value"><xsl:value-of select="res:desc"/></td>
281         </tr>
282       </xsl:if>
283       <xsl:if test="res:params/res:hash">
284         <tr>
285           <td class="label">
286             <xsl:attribute name='rowspan'>
287               <xsl:value-of select='count(res:params/res:hash) + 1'/>
288             </xsl:attribute>
289             Parameters:</td>
290         </tr>
291       </xsl:if>
292       <xsl:apply-templates select="res:params/res:hash"/>
293       <xsl:if test="res:return">
294         <tr>
295           <td class="label">Returns:</td>
296           <td class="value"><xsl:value-of select="res:return/res:desc"/></td>
297         </tr>
298         <tr>
299           <td class="label">Return type:</td>
300           <td class="value"><xsl:value-of select="res:return/res:type"/></td>
301         </tr>
302         <tr>
303           <td class="label">Return type class:</td>
304           <td class="value"><xsl:value-of select="res:return/res:class"/></td>
305         </tr>
306       </xsl:if>
307   </xsl:template>
308
309
310   <!--#if expr="$QUERY_STRING = /service=[^&]+/" -->
311     <!--#if expr="$QUERY_STRING = /param=%22[^&]+%22/" -->
312       <content xmlns="http://example.com/test">
313         <!--#include virtual="/restgateway?${QUERY_STRING}"-->
314       </content>
315     <!--#endif -->
316     <!--#if expr="$QUERY_STRING = /all=on/" -->
317       <content xmlns="http://example.com/test">
318         <!--#include virtual="/restgateway?${QUERY_STRING}"-->
319       </content>
320     <!--#endif -->
321   <!--#endif -->
322
323
324 </xsl:stylesheet>
325