providing option to connect to memcache at general connect time
[OpenSRF.git] / 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://opensrf.org/-/namespaces/gateway/v1"
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="25" -->
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="on" -->
63   <!--#set var="method" value="opensrf.sysemt.method.all" -->
64 <!--#else -->
65   <!--#set var="all" value="off" -->
66   <!--#set var="method" value="opensrf.sysemt.method" -->
67 <!--#endif -->
68
69 <!--#if expr='$QUERY_STRING = /param=%22(.+?)%22/' -->
70   <!--#set var="param" value="$1" -->
71 <!--#else -->
72   <!--#set var="param" value="" -->
73 <!--#endif -->
74
75         <xsl:if test="not(res:response)">
76           <br/><br/><br/><br/><br/><br/>
77           <br/><br/><br/><br/><br/><br/>
78         </xsl:if>
79
80         <form
81           method="GET"
82           action='<!--#echo var="DOCUMENT_URI" -->'
83           onsubmit='
84             this.param.value = "\"" + this.param.value + "\"";
85             if (this.all.checked) this.method.value = "opensrf.system.method.all";
86           '>
87           <xsl:if test="not(res:response)">
88             <xsl:attribute name="style">
89               <xsl:value-of select="'text-align:center;'"/>
90             </xsl:attribute>
91           </xsl:if>
92           Application:
93           <input name="service" type="text" value='<!--#echo var="service" -->'/>&#160;
94           API Method Name Regex:
95           <input name="param" type="text" value='<!--#echo var="param" -->'>
96             <xsl:if test="'<!--#echo var="all" -->' = 'on'">
97               <xsl:attribute name="disabled">
98                 <xsl:value-of select="'true'"/>
99               </xsl:attribute>
100             </xsl:if>
101           </input>&#160;
102           All Methods (Use with care!)
103           <input
104             name="all"
105             type="checkbox"
106             value="on"
107             onclick='
108               if (this.checked) this.form.param.disabled = true;
109               else this.form.param.disabled = false;
110             '>
111             <xsl:if test="'<!--#echo var="all" -->' = 'on'">
112               <xsl:attribute name="checked">
113                 <xsl:value-of select="'checked'"/>
114               </xsl:attribute>
115             </xsl:if>
116
117             </input>&#160;
118           <input type="hidden" name="offset" value="<!--#echo var="offset" -->"/>
119           <button name="limit" value="<!--#echo var="limit" -->">Find 'em</button>
120         </form>
121
122         <xsl:if test="res:response">
123           <hr/>
124
125           <xsl:apply-templates select="res:response"/>
126
127           <hr/>
128
129           <form
130             method="GET"
131             action='<!--#echo var="DOCUMENT_URI" -->'
132             onsubmit='
133               this.param.value = "\"" + this.param.value + "\"";
134               if (this.all.checked) this.method.value = "opensrf.system.method.all";
135             '>
136             <xsl:if test="not(res:response)">
137               <xsl:attribute name="style">
138                 <xsl:value-of select="'text-align:center;'"/>
139               </xsl:attribute>
140             </xsl:if>
141             Application:
142             <input name="service" type="text" value='<!--#echo var="service" -->'/>&#160;
143             API Method Name Regex:
144             <input name="param" type="text" value='<!--#echo var="param" -->'>
145               <xsl:if test="'<!--#echo var="all" -->' = 'on'">
146                 <xsl:attribute name="disabled">
147                   <xsl:value-of select="'true'"/>
148                 </xsl:attribute>
149               </xsl:if>
150             </input>&#160;
151             All Methods (Use with care!)
152             <input
153               name="all"
154               type="checkbox"
155               value="on"
156               onclick='
157                 if (this.checked) this.form.param.disabled = true;
158                 else this.form.param.disabled = false;
159               '>
160               <xsl:if test="'<!--#echo var="all" -->' = 'on'">
161                 <xsl:attribute name="checked">
162                   <xsl:value-of select="'checked'"/>
163                 </xsl:attribute>
164               </xsl:if>
165   
166               </input>&#160;
167             <input type="hidden" name="offset" value="<!--#echo var="offset" -->"/>
168             <button name="limit" value="<!--#echo var="limit" -->">Find 'em</button>
169           </form>
170
171         </xsl:if>
172       </body>
173     </html>
174   </xsl:template>
175
176   <xsl:template name="apiNameLink">
177     API Level: <xsl:value-of select="../res:element[@key='api_level']/res:number"/> / Method: 
178     <a>
179       <xsl:attribute name="href">#<xsl:value-of select="../res:element[@key='api_level']/res:number"/>/<xsl:value-of select="res:string"/></xsl:attribute>
180       <xsl:value-of select="res:string"/>
181     </a>
182     <br/>
183   </xsl:template>
184
185   <xsl:template match="res:response">
186     <xsl:choose>
187       <xsl:when test="count(//res:element[@key='api_name']) > 1 or <!--#echo var="offset" --> > 0">
188         <h1>Matching Methods</h1>
189
190         <xsl:if test="<!--#echo var="offset" --> &gt; 0">
191           <span>
192             <a>
193               <xsl:attribute name="href">docgen.xsl?service=<!--#echo var="service" -->&amp;all=<!--#echo var="all" -->&amp;param="<!--#echo var="param" -->"&amp;limit=<!--#echo var="limit" -->&amp;offset=<xsl:value-of select='<!--#echo var="offset" --> - <!--#echo var="limit" -->'/></xsl:attribute>
194                 Previous Page</a>
195             //
196           </span>
197         </xsl:if>
198
199
200         <span>
201           <xsl:value-of select='<!--#echo var="offset" --> + 1'/>
202             -
203           <xsl:value-of select='<!--#echo var="offset" --> + count(//res:element[@key="api_name"])'/>
204         </span>
205
206         <xsl:if test="count(//res:element[@key='api_name']) = <!--#echo var="limit" -->">
207           <span>
208             //
209             <a>
210               <xsl:attribute name="href">docgen.xsl?service=<!--#echo var="service" -->&amp;all=<!--#echo var="all" -->&amp;param="<!--#echo var="param" -->"&amp;limit=<!--#echo var="limit" -->&amp;offset=<xsl:value-of select='<!--#echo var="offset" --> + <!--#echo var="limit" -->'/></xsl:attribute>
211                 Next Page</a>
212           </span>
213         </xsl:if>
214
215         <br/>
216         <br/>
217
218         <xsl:for-each select="//res:element[@key='api_name']">
219           <xsl:sort select="concat(../res:element[@key='api_level']/res:number/text(), res:string/text())"/>
220           <xsl:call-template name="apiNameLink"/>
221         </xsl:for-each>
222
223         <h1>Method Definitions</h1>
224       </xsl:when>
225       <xsl:when test="count(//res:element[@key='api_name']) = 0">
226         <h1><i>No Matching Methods Found</i></h1>
227       </xsl:when>
228     </xsl:choose>
229
230     <xsl:for-each select="res:payload/res:object">
231       <xsl:sort select="concat(../res:element[@key='api_level']/res:number/text(), res:string/text())"/>
232       <xsl:call-template name="methodDefinition"/>
233     </xsl:for-each>
234   </xsl:template>
235
236
237   <xsl:template name="methodDefinition">
238     <xsl:if test="res:element[@key='remote']/res:number/text()='0'">
239
240       <xsl:if test="count(//res:element[@key='api_name']) > 1">
241         <a>
242           <xsl:attribute name="name"><xsl:value-of select="res:element[@key='api_level']/res:number"/>/<xsl:value-of select="res:element[@key='api_name']/res:string"/></xsl:attribute>
243         </a>
244         <a href="#top">Top</a>
245       </xsl:if>
246
247       <table>
248         <tr>
249           <td colspan="3" class="header"><xsl:value-of select="res:element[@key='api_name']/res:string"/></td>
250         </tr>
251         <tr>
252           <td class="label">API Level:</td>
253           <td colspan="2" class="value"><xsl:value-of select="res:element[@key='api_level']/res:number"/></td>
254         </tr>
255         <tr>
256           <td class="label">Package:</td>
257           <td colspan="2" class="value"><xsl:value-of select="res:element[@key='package']/res:string"/></td>
258         </tr>
259         <tr>
260           <td class="label">Packaged Method:</td>
261           <td colspan="2" class="value"><xsl:value-of select="res:element[@key='method']/res:string"/></td>
262         </tr>
263         <tr>
264           <td class="label">Required argument count:</td>
265           <td colspan="2" class="value"><xsl:value-of select="res:element[@key='argc']/res:number"/></td>
266         </tr>
267         <xsl:if test="normalize-space(res:element[@key='signature']/res:object/res:element[@key='desc']/res:string/text()) != normalize-space(res:element[@key='notes']/res:string/text())">
268           <tr>
269             <td class="label">
270               <xsl:attribute name='rowspan'>
271                 <xsl:value-of select='
272                   count(res:element[@key="signature"]/res:object/res:element[@key="params"]/res:array/res:object) +
273                   count(res:element[@key="signature"]/res:object/res:element[@key="params"]/res:array[res:object]) +
274                   5
275                 '/>
276               </xsl:attribute>
277               Signature:
278             </td>
279           </tr>
280           <xsl:for-each select="res:element[@key='signature']/res:object">
281             <xsl:call-template name="methodSignature"/>
282           </xsl:for-each>
283         </xsl:if>
284         <tr>
285           <td class="label">Streaming method:</td>
286           <td colspan="2" class="value">
287             <xsl:if test="res:element[@key='stream']/res:number/text()='1'">Yes</xsl:if>
288             <xsl:if test="res:element[@key='stream']/res:number/text()='0'">No</xsl:if>
289           </td>
290         </tr>
291         <xsl:if test="res:element[@key='notes']">
292           <tr>
293             <td class="label">Notes:</td>
294             <td colspan="2" class="value"><pre style="font-weight:normal;font-size:10px;"><xsl:value-of select="res:element[@key='notes']/res:string"/></pre></td>
295           </tr>
296         </xsl:if>
297       </table>
298     </xsl:if>
299   </xsl:template>
300
301
302   <xsl:template name="paramInfoLine">
303     <tr>
304       <td class="label params">
305         <xsl:if test="@key='name'">Name:</xsl:if>
306         <xsl:if test="@key='desc'">Description:</xsl:if>
307         <xsl:if test="@key='type'">Data type:</xsl:if>
308         <xsl:if test="@key='class'">Object class:</xsl:if>
309       </td>
310       <td class="value params"><xsl:value-of select="res:string"/></td>
311     </tr>
312   </xsl:template>
313
314
315   <xsl:template name="paramInfo">
316     <tr>
317       <td>
318         <table class="params">
319           <tr>
320             <td class="label params">Position:</td>
321             <td class="value params"><xsl:value-of select="position()"/></td>
322           </tr>
323           <xsl:for-each select="res:element">
324                 <xsl:call-template name="paramInfoLine"/>
325           </xsl:for-each>
326         </table>
327       </td>
328     </tr>
329   </xsl:template>
330
331
332   <xsl:template name="methodSignature">
333       <xsl:if test="res:element[@key='desc']">
334         <tr>
335           <td class="label">Description:</td>
336           <td class="value"><xsl:value-of select="res:element[@key='desc']/res:string"/></td>
337         </tr>
338       </xsl:if>
339       <xsl:if test="res:element[@key='params']/res:array/res:object">
340         <tr>
341           <td class="label">
342             <xsl:attribute name='rowspan'>
343               <xsl:value-of select='count(res:element[@key="params"]/res:array/res:object) + 1'/>
344             </xsl:attribute>
345             Parameters:</td>
346         </tr>
347       </xsl:if>
348       <xsl:for-each select="res:element[@key='params']/res:array/res:object">
349         <xsl:sort select="position()"/>
350         <xsl:call-template name="paramInfo"/>
351       </xsl:for-each>
352       <xsl:if test="res:element[@key='return']">
353         <tr>
354           <td class="label">Returns:</td>
355           <td class="value"><xsl:value-of select="res:element[@key='return']/res:object/res:element[@key='desc']/res:string"/></td>
356         </tr>
357         <tr>
358           <td class="label">Return type:</td>
359           <td class="value"><xsl:value-of select="res:element[@key='return']/res:object/res:element[@key='type']/res:string"/></td>
360         </tr>
361         <tr>
362           <td class="label">Return type class:</td>
363           <td class="value"><xsl:value-of select="res:element[@key='return']/res:object/res:element[@key='class']/res:string"/></td>
364         </tr>
365       </xsl:if>
366   </xsl:template>
367
368
369   <!--#if expr="$QUERY_STRING = /service=[^&]+/" -->
370     <!--#if expr="$QUERY_STRING = /param=%22[^&]+%22/" -->
371       <!-- virtual="/gateway?format=xml&${QUERY_STRING}"-->
372       <!-- virtual="/restgateway?${QUERY_STRING}"-->
373       <!--#include virtual='/gateway?format=xml&service=$service&method=opensrf.system.method&param="$param"&param=$limit&param=$offset'-->
374     <!--#endif -->
375     <!--#if expr="$QUERY_STRING = /all=on/" -->
376       <!-- virtual="/gateway?format=xml&${QUERY_STRING}"-->
377       <!-- virtual="/restgateway?${QUERY_STRING}"-->
378       <!--#include virtual='/gateway?format=xml&service=$service&method=opensrf.system.method.all&param=$limit&param=$offset' -->
379     <!--#endif -->
380   <!--#endif -->
381
382
383 </xsl:stylesheet>
384