comparison src/org/ssdt_ohio/tools/ant/wsd2html.xsl @ 2:09f9f3d5c507

CM-127: Move wsdlsetup and wsd2html.xsl from Tools
author smith@nwoca.org
date Tue, 07 Jun 2011 18:06:07 -0400
parents
children
comparison
equal deleted inserted replaced
1:82fc5e17cc59 2:09f9f3d5c507
1 <?xml version="1.0"?>
2 <xsl:stylesheet
3 version="1.0"
4 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
6 xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
7 xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
8 xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
9 xmlns:x="http://ssdt.nwoca.org/xml/wsdl2html"
10 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
11
12 <xsl:output method="html" omit-xml-declaration="yes"/>
13 <xsl:variable name="wsd2htmlVersion" select="'ssdt wsd2html 0.2-0'"/>
14 <xsl:variable name="defaultNamespace">
15 <xsl:for-each select="wsdl:definitions/namespace::*">
16 <xsl:if test="not(name())">
17 <xsl:value-of select="."/>
18 </xsl:if>
19 </xsl:for-each>
20 </xsl:variable>
21 <xsl:variable name="targetNamespace" select="wsdl:definitions/@targetNamespace"/>
22
23 <xsl:template match="/">
24 <HTML>
25 <HEAD>
26 <TITLE>Web Service Description: <xsl:value-of select="wsdl:definitions/wsdl:service/@name"/>
27 </TITLE>
28 <META HTTP-EQUIV="content-type" content="text/html" charset="UTF-8"/>
29 <STYLE TYPE="text/css">
30 BODY {
31 margin-left: 5%;
32 margin-right: 5%;
33 }
34 H1 {
35 background-color: lightgrey;
36 }
37 H2 {
38 background-color: lightgrey;
39 }
40 H3 {
41 background-color: #00CCCC;
42 text-indent: .5em;
43 border: thin solid black;
44 width: 95%;
45 }
46 P {
47 }
48 TABLE {
49 border: thin solid black;
50 left-margin: 20em;
51 width: 80%;
52 }
53 TD {
54 border: thin solid black;
55 padding: .2em;
56 }
57 .xml {
58 border: thin dotted blue;
59 padding: .5em;
60 width: 70%;
61 margin-left: 5%;
62 }
63 .xml UL LI {
64 list-style-image: none;
65 list-style-type: none;
66 }
67 .attrValue {
68 color: rgb(153, 51, 51);
69 font-weight: bold;
70 }
71 .attrName {
72 color: rgb(0, 0, 102);
73 }
74 .xmlElement {
75 color: black;
76 font-weight: bold;
77 }
78
79 </STYLE>
80 </HEAD>
81 <BODY>
82 <H1>Web Service Description: <xsl:value-of select="wsdl:definitions/wsdl:service/@name"/>
83 </H1>
84 <h2>Contents</h2>
85 <ul>
86 <li>
87 <a href="#operations">Operations</a>
88 </li>
89 <li>
90 <a href="#messages">Messages</a>
91 </li>
92 <li>
93 <a href="#elements">Elements</a>
94 </li>
95 <li>
96 <a href="#types">Types</a>
97 </li>
98 </ul>
99 <hr/>
100
101
102 <xsl:call-template name="getDoc">
103 <xsl:with-param name="doc" select="wsdl:definitions/wsdl:documentation"/>
104 </xsl:call-template>
105
106 <HR/>
107
108 <xsl:apply-templates select="wsdl:definitions/wsdl:service"/>
109
110 <hr/>
111
112 <h2>Namespaces:</h2>
113 <table>
114 <tr>
115 <th>Prefix</th>
116 <th>Namespace</th>
117 </tr>
118 <xsl:for-each select="wsdl:definitions/namespace::*">
119 <xsl:sort select="name()"/>
120 <tr>
121 <td>
122 <xsl:choose>
123 <xsl:when test="name()">
124 <xsl:value-of select="name()"/>
125 </xsl:when>
126 <xsl:otherwise>
127 <xsl:text>[Default]</xsl:text>
128 </xsl:otherwise>
129 </xsl:choose>
130 </td>
131 <td>
132 <xsl:value-of select="."/>
133 </td>
134 </tr>
135 </xsl:for-each>
136 </table>
137
138 <h2>Imported Schemas</h2>
139
140 <table>
141 <tr>
142 <th>Namespace</th>
143 <th>Location</th>
144 </tr>
145 <xsl:for-each select="wsdl:definitions/wsdl:types/xsd:schema/xsd:import">
146 <tr>
147 <td>
148 <xsl:value-of select="@namespace"/>
149 </td>
150 <td>
151 <xsl:value-of select="@schemaLocation"/>
152 </td>
153 </tr>
154 </xsl:for-each>
155 </table>
156
157 <HR/>
158 <a name="operations" id="operations"/>
159 <H2>Port Type: <xsl:value-of select="wsdl:definitions/wsdl:portType/@name"/>
160 </H2>
161 <xsl:apply-templates select="wsdl:definitions/wsdl:portType"/>
162
163 <H2>Operations Detail</H2>
164 <xsl:apply-templates select="wsdl:definitions/wsdl:portType/wsdl:operation">
165 <xsl:sort select="@name"/>
166 </xsl:apply-templates>
167
168 <a name="messages" id="messages"/>
169 <H2>Messsages</H2>
170 <table>
171 <tr><th>Message</th><th>Parameter</th></tr>
172 <xsl:apply-templates select="wsdl:definitions/wsdl:message">
173 <xsl:sort select="@name"/>
174 </xsl:apply-templates>
175 </table>
176
177 <a name="elements" id="elements"/>
178 <H2>Elements</H2>
179 <ul>
180 <xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:element" mode="summary">
181 <xsl:sort select="@name"/>
182 </xsl:apply-templates>
183 </ul>
184 <xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:element" mode="detail">
185 <xsl:sort select="@name"/>
186 </xsl:apply-templates>
187
188 <a name="types" id="types"/>
189 <H2>Types</H2>
190 <ul>
191 <xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:complexType | wsdl:definitions/wsdl:types/xsd:schema/xsd:simpleType"
192 mode="summary">
193 <xsl:sort select="@name"/>
194 </xsl:apply-templates>
195 </ul>
196 <hr/>
197
198 <xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:complexType | wsdl:definitions/wsdl:types/xsd:schema/xsd:simpleType"
199 mode="detail">
200 <xsl:sort select="@name"/>
201 </xsl:apply-templates>
202
203 <hr/>
204 <i><font size="-1">Generated by <xsl:value-of select="$wsd2htmlVersion"/></font></i>
205 </BODY>
206 </HTML>
207 </xsl:template>
208
209 <xsl:template match="wsdl:operation">
210 <a name="o-{@name}" id="o-{@name}"/>
211 <h3>Operation: <xsl:value-of select="@name"/>
212 </h3>
213 <xsl:call-template name="getDoc">
214 <xsl:with-param name="doc" select="wsdl:documentation"/>
215 </xsl:call-template>
216 <table>
217 <tr>
218 <td>Input</td>
219 <td>
220 <a href="#m-{wsdl:input/@name}">
221 <xsl:value-of select="wsdl:input/@name"/>
222 </a>
223 </td>
224 </tr>
225 <tr>
226 <td>Output</td>
227 <td>
228 <a href="#m-{wsdl:output/@name}">
229 <xsl:value-of select="wsdl:output/@name"/>
230 </a>
231 </td>
232 </tr>
233 <xsl:for-each select="wsdl:fault">
234 <tr>
235 <td>Fault</td>
236 <td>
237 <xsl:variable name="typeName">
238 <xsl:call-template name="getQname">
239 <xsl:with-param name="elementName" select="@name"/>
240 </xsl:call-template>
241 </xsl:variable>
242 <xsl:variable name="anchor">
243 <xsl:call-template name="getAnchor">
244 <xsl:with-param name="anchorText" select="$typeName"/>
245 </xsl:call-template>
246 </xsl:variable>
247 <a href="#ty-{$anchor}">
248 <xsl:value-of select="@name"/>
249 </a>
250
251 </td>
252 <td>
253 <xsl:call-template name="getDoc">
254 <xsl:with-param name="doc" select="wsdl:documentation"/>
255 </xsl:call-template>
256
257 </td>
258 </tr>
259 </xsl:for-each>
260 </table>
261
262 </xsl:template>
263
264 <xsl:template match="wsdl:message">
265 <tr><td>
266 <a name="m-{@name}" id="m-{@name}"/>
267
268 <xsl:value-of select="@name"/>
269 </td><td>
270 <xsl:variable name="typeName">
271 <xsl:call-template name="getQname">
272 <xsl:with-param name="elementName" select="wsdl:part/@element"/>
273 </xsl:call-template>
274 </xsl:variable>
275 <xsl:variable name="anchor">
276 <xsl:call-template name="getAnchor">
277 <xsl:with-param name="anchorText" select="$typeName"/>
278 </xsl:call-template>
279 </xsl:variable>
280 <a href="#e-{$anchor}"> <xsl:value-of select="$typeName"/>
281 </a>
282 </td></tr>
283
284 </xsl:template>
285
286 <xsl:template name="getAnchor">
287 <xsl:param name="anchorText"/>
288 <xsl:value-of select="translate(normalize-space($anchorText),':/.[]', '_____')"/>
289 </xsl:template>
290
291 <xsl:template name="getQname">
292 <xsl:param name="elementName"/>
293 <xsl:choose>
294 <xsl:when test="contains($elementName,':')">
295 [<xsl:value-of select="/wsdl:definitions/namespace::*[name()=substring-before($elementName,':')]"/>]:<xsl:value-of select="substring-after($elementName,':')"/>
296 </xsl:when>
297 <xsl:otherwise>
298 [<xsl:value-of select="$defaultNamespace"/>]:<xsl:value-of select="$elementName"/>
299 </xsl:otherwise>
300 </xsl:choose>
301 </xsl:template>
302
303
304
305
306 <xsl:template match="xsd:element" mode="summary">
307 <xsl:variable name="typeName">
308 <xsl:call-template name="getQname">
309 <xsl:with-param name="elementName" select="@name"/>
310 </xsl:call-template>
311 </xsl:variable>
312 <xsl:variable name="anchor">
313 <xsl:call-template name="getAnchor">
314 <xsl:with-param name="anchorText" select="$typeName"/>
315 </xsl:call-template>
316 </xsl:variable>
317 <li><a href="#e-{$anchor}"><xsl:value-of select="@name"/></a></li>
318 </xsl:template>
319
320
321 <xsl:template match="xsd:element" mode="detail">
322
323 <xsl:variable name="typeName">
324 <xsl:call-template name="getQname">
325 <xsl:with-param name="elementName" select="@name"/>
326 </xsl:call-template>
327 </xsl:variable>
328 <xsl:variable name="anchor">
329 <xsl:call-template name="getAnchor">
330 <xsl:with-param name="anchorText" select="$typeName"/>
331 </xsl:call-template>
332 </xsl:variable>
333
334 <a name="e-{$anchor}" id="e-{$anchor}"/>
335 <h3>
336 <xsl:value-of select="$typeName"/>
337 </h3>
338 <div class="xml">
339 <xsl:call-template name="codeXml"/>
340 </div>
341 </xsl:template>
342
343
344
345 <xsl:template match="xsd:complexType | xsd:simpleType" mode="summary">
346 <xsl:variable name="typeName">
347 <xsl:call-template name="getQname">
348 <xsl:with-param name="elementName" select="@name"/>
349 </xsl:call-template>
350 </xsl:variable>
351 <xsl:variable name="anchor">
352 <xsl:call-template name="getAnchor">
353 <xsl:with-param name="anchorText" select="$typeName"/>
354 </xsl:call-template>
355 </xsl:variable>
356
357 <li><a href="#ty-{$anchor}"><xsl:value-of select="@name"/></a></li>
358 </xsl:template>
359
360
361
362 <xsl:template match="xsd:complexType | xsd:simpleType" mode="detail">
363 <xsl:variable name="typeName">
364 <xsl:call-template name="getQname">
365 <xsl:with-param name="elementName" select="@name"/>
366 </xsl:call-template>
367 </xsl:variable>
368 <xsl:variable name="anchor">
369 <xsl:call-template name="getAnchor">
370 <xsl:with-param name="anchorText" select="$typeName"/>
371 </xsl:call-template>
372 </xsl:variable>
373
374 <a name="ty-{$anchor}" id="ty-{$anchor}"/>
375 <h3>
376 <xsl:value-of select="@name"/>
377 </h3>
378 <div class="xml">
379 <xsl:call-template name="codeXml"/>
380 </div>
381 </xsl:template>
382
383 <xsl:template match="wsdl:service">
384 <h2>Service Summary: Service: <xsl:value-of select="@name"/>
385 </h2>
386 <xsl:for-each select="wsdl:port">
387 <p>Port name: <xsl:value-of select="@name"/>
388 <br/>
389 Endpoint URL: <xsl:value-of select="*[local-name()='address']/@location"/>
390 <br/>
391 Binding: <xsl:value-of select="@binding"/>
392 </p>
393 </xsl:for-each>
394 </xsl:template>
395
396 <xsl:template match="wsdl:portType">
397 Operations:
398 <table>
399 <tr><th>Operation</th>
400 <th>Description</th>
401 </tr>
402 <xsl:for-each select="wsdl:operation">
403 <xsl:sort select="@name"/>
404 <tr>
405 <td>
406 <a href="#o-{@name}">
407 <xsl:value-of select="@name"/>
408 </a>
409 </td>
410 <td>
411 <xsl:call-template name="getShortDescription">
412 <xsl:with-param name="desc" select="wsdl:documentation"/>
413 </xsl:call-template>
414 </td>
415 </tr>
416 </xsl:for-each>
417 </table>
418 </xsl:template>
419
420 <xsl:template name="getShortDescription">
421 <xsl:param name="desc"/>
422 <xsl:choose>
423 <xsl:when test="contains($desc,'.')">
424 <xsl:value-of select="substring-before($desc,'.')"/>
425 </xsl:when>
426 <xsl:otherwise>
427 <xsl:value-of select="$desc"/>
428 </xsl:otherwise>
429 </xsl:choose>.
430 </xsl:template>
431
432 <xsl:template name="codeXml">
433 <xsl:choose>
434 <xsl:when test="name()='xsd:annotation'">
435 <UL>
436 <LI>
437 <P>
438 <xsl:call-template name="getDoc">
439 <xsl:with-param name="doc" select="xsd:documentation"/>
440 </xsl:call-template>
441 </P>
442 </LI>
443 </UL>
444 </xsl:when>
445 <xsl:otherwise>
446 <ul>
447 <li>&lt;<span class="xmlElement"><xsl:value-of select="name()"/></span>
448 <xsl:for-each select="@*"><xsl:text> </xsl:text>
449 <span class="attrName"><xsl:value-of select="name()"/></span>="<span class="attrValue"><xsl:value-of select="."/>
450 </span>"
451 </xsl:for-each>
452 <xsl:choose>
453 <xsl:when test="count(*) = 0">
454 <xsl:text>/&gt;</xsl:text>
455 </xsl:when>
456 <xsl:otherwise>
457 &gt;
458 <xsl:for-each select="*">
459 <xsl:call-template name="codeXml"/>
460 </xsl:for-each>
461 &lt;/<span class="xmlElement"><xsl:value-of select="name()"/></span>&gt;
462 </xsl:otherwise>
463 </xsl:choose>
464 </li>
465 </ul>
466 </xsl:otherwise>
467 </xsl:choose>
468 </xsl:template>
469
470 <xsl:template name="getDoc">
471 <xsl:param name="doc"/>
472 <xsl:choose>
473 <xsl:when test="$doc/*">
474 <xsl:copy-of select="$doc/*"/>
475 </xsl:when>
476 <xsl:otherwise>
477 <xsl:value-of select="$doc/text()"/>
478 </xsl:otherwise>
479 </xsl:choose>
480 </xsl:template>
481
482 </xsl:stylesheet>