Author: jonathan
Date: Mon Dec  3 12:33:56 2007
New Revision: 10454

Log:

MASHUP-377: New format for ?doc option.

Modified:
   trunk/commons/dynamic-codegen/src/doc.xslt

Modified: trunk/commons/dynamic-codegen/src/doc.xslt
==============================================================================
--- trunk/commons/dynamic-codegen/src/doc.xslt  (original)
+++ trunk/commons/dynamic-codegen/src/doc.xslt  Mon Dec  3 12:33:56 2007
@@ -1,153 +1,314 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
 
-<xsl:output method="html" indent="yes"/>
-
-<xsl:param name="service" select="services/service[1]/@name"/>
-
-<xsl:template match="/">
-    <xsl:apply-templates select="services/[EMAIL PROTECTED]"/>
-</xsl:template>
-
-<xsl:template match="service">
-    <xsl:variable name="service-name">
-        <xsl:call-template name="xml-name-to-javascript-name">
-            <xsl:with-param name="name" select="@name"/>
-        </xsl:call-template>
-    </xsl:variable>
-
-    <html>
-        <head>
-            <title><xsl:value-of select="$service-name"/> service 
documentation</title>
-            <style type="text/css">
-                body {font: 75%/1.5 "Lucida Grande","Lucida Sans","Microsoft 
Sans Serif", "Lucida Sans Unicode",verdana,sans-serif,"trebuchet ms"; color: 
#111; margin:0px; padding:0px}
-                td {font-size:75%}
-                .title {font-size: large; background-color:#BFC; padding:1em 
.5em .5em .5em; margin:0px}
-                .subtitle {margin-top:.5em; font-weight:bold; font-size:140%}
-                .content {padding:1em}
-                table.operations {margin:0em .5em .5em 1em}
-                tr.operation {vertical-align:top; padding-top:3em}
-                td.operationName {white-space:nowrap; padding-right:1.5em; 
font-weight:bold}
-                tr.parameters {vertical-align:top}
-                td.parameter {padding:0em .5em 0em 1.5em}
-                td.return {white-space:nowrap; padding: 0em .5em 1em 1.5em}
-                td.type {font-style:italic}
-                td.blank {width:70%}
-                .documentation {margin-bottom:.5em}
-                .documentationHeading {margin-bottom:.5em; font-weight:bold}
-                ul {margin-top:.25em}
-            </style>
-        </head>
-        <body>
-            <h1 class="title"><em><xsl:value-of select="$service-name"/></em> 
service documentation</h1>
-            <div class="content">
-                <xsl:if test="documentation/node()">
-                    <div class="description">
-                        <!-- MASHUP-65 workaround -->
-                        <xsl:choose>
-                            <xsl:when test="not(documentation/*) and 
starts-with(documentation,'&lt;')"><xsl:value-of select="documentation" 
disable-output-escaping="yes"/></xsl:when>
-                            <xsl:otherwise><xsl:copy-of 
select="documentation/node()"/></xsl:otherwise>
-                        </xsl:choose>
-                    </div>
+    <xsl:output method="html" indent="yes"/>
+
+    <!-- This stylesheet only supports a single service at a time.
+             If no service name is specified in this parameter, the first one 
is used.  -->
+    <xsl:param name="service" select="services/service[1]/@name"/>
+
+    <!-- Paths to external resources can be specified here. -->
+    <xsl:param name="image-path" select="'../images/'"/>
+    <xsl:param name="enable-header" select="'true'"/>
+    <xsl:param name="enable-footer" select="'true'"/>
+
+    <!-- Allows some html to be inserted immediately before the body. -->
+    <xsl:param name="breadcrumbs" />
+
+    <xsl:template match="/">
+        <xsl:apply-templates select="services/[EMAIL PROTECTED]"/>
+    </xsl:template>
+
+    <xsl:template match="service">
+        <xsl:variable name="service-name">
+            <xsl:call-template name="xml-name-to-javascript-name">
+                <xsl:with-param name="name" select="@name"/>
+            </xsl:call-template>
+        </xsl:variable>
+
+        <html>
+            <head>
+                <title><xsl:value-of select="$service-name"/> service 
documentation</title>
+                <xsl:call-template name="css"/>
+            </head>
+            <body>
+                <!-- insert breadcrumbs -->
+                <xsl:value-of select="$breadcrumbs" 
disable-output-escaping="yes"/>
+                <!-- header -->
+                <xsl:if test="$enable-header='true'">
+                 <div id="header">
+                     <nobr>
+                        <div id="logo">
+                        <a href="http://wso2.com";><img 
src="{$image-path}wso2-logo.gif"/></a>
+                        </div>
+                        <h1><xsl:value-of select="$service-name"/> service 
documentation</h1>
+                    </nobr>
+                 </div>
                 </xsl:if>
-                <div class="operations">
-                    <div class="subtitle"><xsl:value-of 
select="$service-name"/> operations</div>
-                    <xsl:apply-templates select="operations"/>
-                </div>
-                <div class="subtitle">Additional resources</div>
-                <div class="resources">
-                    <xsl:variable name="insecure-endpoint" 
select="/services/service[starts-with(@address, 'http:')][1]/@address"/>
-                    <xsl:variable name="secure-endpoint" 
select="/services/service[starts-with(@address, 'https:')][1]/@address"/>
-                    <xsl:variable name="endpoint">
-                        <xsl:choose>
-                            <xsl:when test="$insecure-endpoint"><xsl:value-of 
select="$insecure-endpoint"/></xsl:when>
-                            <xsl:when test="$secure-endpoint"><xsl:value-of 
select="$secure-endpoint"/></xsl:when>
-                        </xsl:choose>
-                    </xsl:variable>
-                    <ul compact="compact">
-                        <li>Try the service with an on-line 
-                            <xsl:if test="$insecure-endpoint">
-                                <a alt="HTTP Try-it page" 
href="{$insecure-endpoint}?tryit">HTTP</a>
-                            </xsl:if>
-                            <xsl:if test="$insecure-endpoint and 
$secure-endpoint"> or </xsl:if>
-                            <xsl:if test="$secure-endpoint">
-                                <a alt="HTTPS Try-it page" 
href="{$secure-endpoint}?tryit">HTTPS</a>
-                            </xsl:if>
-                            AJAX client.</li>
-                        <li>View the <a alt="Source Code" 
href="{$endpoint}?source">Source Code</a> of the service.</li>
-                        <li>View the <a alt="WSDL 2.0" 
href="{$endpoint}?wsdl2&amp;annotation=true">WSDL 2.0</a> description.</li>
-                        <li>View the <a alt="WSDL 1.1" 
href="{$endpoint}?wsdl&amp;annotation=true">WSDL 1.1</a> description.</li>
-                        <li>View the <a alt="XML Schema" 
href="{$endpoint}?xsd&amp;annotation=true">XML Schema</a> of the message 
types.</li>
-                     </ul>
+                <!-- end of header -->
+                <div id="body">
+                    <xsl:if test="documentation/node()">
+                        <div id="intro">
+                            <div class="documentation">
+                                <!-- MASHUP-65 workaround -->
+                                <xsl:choose>
+                                    <xsl:when test="not(documentation/*) and 
starts-with(documentation,'&lt;')"><xsl:value-of select="documentation" 
disable-output-escaping="yes"/></xsl:when>
+                                    <xsl:otherwise><xsl:copy-of 
select="documentation/node()"/></xsl:otherwise>
+                                </xsl:choose>
+                            </div>
+                        </div>
+                    </xsl:if>
+                    <div id="middle">
+                        <div id="operations">
+                            <div class="subtitle"><xsl:value-of 
select="$service-name"/> operations</div>
+                            <xsl:apply-templates select="operations"/>
+                        </div>
+                        <div class="resources">
+                            <xsl:variable name="insecure-endpoint" 
select="/services/service[starts-with(@address, 'http:')][1]/@address"/>
+                            <xsl:variable name="secure-endpoint" 
select="/services/service[starts-with(@address, 'https:')][1]/@address"/>
+                            <xsl:variable name="endpoint">
+                                <xsl:choose>
+                                    <xsl:when 
test="$insecure-endpoint"><xsl:value-of select="$insecure-endpoint"/></xsl:when>
+                                    <xsl:when 
test="$secure-endpoint"><xsl:value-of select="$secure-endpoint"/></xsl:when>
+                                </xsl:choose>
+                            </xsl:variable>
+                            <div class="subtitle">Additional resources</div>
+                            <ul compact="compact">
+                                <li>Try the service with an on-line
+                                    <xsl:if test="$insecure-endpoint">
+                                        <a alt="HTTP Try-it page" 
href="{$insecure-endpoint}?tryit">HTTP</a>
+                                    </xsl:if>
+                                    <xsl:if test="$insecure-endpoint and 
$secure-endpoint"> or </xsl:if>
+                                    <xsl:if test="$secure-endpoint">
+                                        <a alt="HTTPS Try-it page" 
href="{$secure-endpoint}?tryit">HTTPS</a>
+                                    </xsl:if>
+                                    AJAX client.</li>
+                                <li>View the <a alt="Source Code" 
href="{$endpoint}?source">Source Code</a> of the service.</li>
+                                <li>View the <a alt="WSDL 2.0" 
href="{$endpoint}?wsdl2&amp;annotation=true">WSDL 2.0</a> description.</li>
+                                <li>View the <a alt="WSDL 1.1" 
href="{$endpoint}?wsdl&amp;annotation=true">WSDL 1.1</a> description.</li>
+                                <li>View the <a alt="XML Schema" 
href="{$endpoint}?xsd&amp;annotation=true">XML Schema</a> of the message 
types.</li>
+                             </ul>
+                        </div>
+                    </div>
                 </div>
-            </div>
-        </body> 
-    </html>
-</xsl:template>
-    
-<xsl:template match="operations">
-    <table class="operations">
-        <xsl:apply-templates />
-    </table>    
-</xsl:template>
-
-<xsl:template match="operation">
-    <xsl:variable name="name">
-        <xsl:call-template name="xml-name-to-javascript-name">
-            <xsl:with-param name="name" select="@name"/>
-        </xsl:call-template>
-    </xsl:variable>
-    <tr class="operation">
-        <td class="operationName" rowspan="{count(signature/params/param) 
+2}"><xsl:value-of select="$name"/>
-            <xsl:text> (</xsl:text>
-            <xsl:for-each select="signature/params/param">
-                <xsl:if test="position() != 1">, </xsl:if>
-                <xsl:if test="(position() mod 4) = 
0"><br/>&#160;&#160;&#160;</xsl:if>
-                <xsl:value-of select="@name"/>
-            </xsl:for-each>
-            <xsl:text>)</xsl:text>
-        </td>
-        <td colspan="3">
-            <xsl:if test="documentation/node()">
-                <div class="documentation">
-                    <!-- MASHUP-65 workaround -->
-                    <xsl:choose>
-                        <xsl:when test="not(documentation/*) and 
starts-with(documentation,'&lt;')"><xsl:value-of select="documentation" 
disable-output-escaping="yes"/></xsl:when>
-                        <xsl:otherwise><xsl:copy-of 
select="documentation/node()"/></xsl:otherwise>
-                    </xsl:choose>
-                </div>
-            </xsl:if>
-            <div class="documentationHeading">Parameters:</div>
-        </td>
-    </tr>
-    <xsl:for-each select="signature/params/param">
-        <tr class="parameters">
-            <td class="parameter"><xsl:value-of select="@name"/></td>
-            <td class="type"><xsl:value-of select="@type"/></td>
-            <td class="blank"/>
-        </tr>
-    </xsl:for-each>
-    <xsl:for-each select="signature/returns/param">
-        <tr class="parameters">
-            <td class="return">(return value)</td>
-            <td class="type"><xsl:value-of select="@type"/></td>
-            <td class="blank"/>
+                <!-- footer -->
+                <xsl:if test="$enable-footer='true'">
+                  <div id="footer">© 2007 WSO2</div>
+                </xsl:if>
+                <!-- end of footer -->                
+            </body>
+        </html>
+    </xsl:template>
+
+    <xsl:template match="operations">
+        <table id="operationsTable">
+            <xsl:apply-templates />
+        </table>
+    </xsl:template>
+
+    <xsl:template match="operation">
+        <xsl:variable name="name">
+            <xsl:call-template name="xml-name-to-javascript-name">
+                <xsl:with-param name="name" select="@name"/>
+            </xsl:call-template>
+        </xsl:variable>
+        <tr class="operation">
+            <td class="operationName"><xsl:value-of select="$name"/>
+                <xsl:text> (</xsl:text>
+                <xsl:for-each select="signature/params/param">
+                    <xsl:if test="position() != 1">, </xsl:if>
+                    <xsl:if test="(position() mod 4) = 
0"><br/>&#160;&#160;&#160;</xsl:if>
+                    <xsl:value-of select="@name"/>
+                </xsl:for-each>
+                <xsl:text>)</xsl:text>
+            </td>
+            <td>
+                <xsl:if test="documentation/node()">
+                    <div class="documentation">
+                        <!-- MASHUP-65 workaround -->
+                        <xsl:choose>
+                            <xsl:when test="not(documentation/*) and 
starts-with(documentation,'&lt;')"><xsl:value-of select="documentation" 
disable-output-escaping="yes"/></xsl:when>
+                            <xsl:otherwise><xsl:copy-of 
select="documentation/node()"/></xsl:otherwise>
+                        </xsl:choose>
+                    </div>
+                </xsl:if>
+                <xsl:apply-templates select="signature"/>
+            </td>
         </tr>
-    </xsl:for-each>
-</xsl:template>
-
-<xsl:template name="return-type">
-    <xsl:text>/* </xsl:text>
-    <xsl:if test="@maxOccurs = 'unbounded' or @maxOccurs > 1">array of 
</xsl:if>
-    <xsl:call-template name="xml-name-to-javascript-name">
-        <xsl:with-param name="name" select="@type"/>
-    </xsl:call-template>
-    <xsl:text>*/</xsl:text>
-</xsl:template>
-
-<xsl:template name="xml-name-to-javascript-name">
-    <xsl:param name="name"/>
-    <xsl:value-of select="translate($name,'.-','__')"/>
-</xsl:template>
+    </xsl:template>
+
+    <xsl:template match="signature">
+         <table class="params" cellspacing="0" cellpadding="0">
+             <tr>
+                 <th colspan="2">
+                     Parameters:
+                 </th>
+             </tr>
+             <xsl:for-each select="params/param">
+                <tr class="parameters">
+                    <td class="parameter"><xsl:value-of select="@name"/></td>
+                    <td class="type"><xsl:apply-templates select="@type"/></td>
+                </tr>
+            </xsl:for-each>
+            <xsl:for-each select="returns/param">
+                <tr class="parameters">
+                    <td class="return">(return value)</td>
+                    <td class="type"><xsl:apply-templates select="@type"/></td>
+                </tr>
+            </xsl:for-each>
+         </table>
+    </xsl:template>
+
+    <xsl:template match="param/@type">
+        <xsl:choose>
+            <xsl:when test="../enumeration">
+                <span class="enumeration">
+                    <xsl:for-each select="../enumeration">
+                        <xsl:if test="position() > 1"> | </xsl:if>
+                        <xsl:value-of select="@value"/>
+                    </xsl:for-each>
+                </span>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="."/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:template>
+
+    <xsl:template name="xml-name-to-javascript-name">
+        <xsl:param name="name"/>
+        <xsl:value-of select="translate($name,'.-','__')"/>
+    </xsl:template>
+
+    <!-- template for inserting CSS -->
+    <xsl:template name="css">
+        <!-- css is embedded rather than linked so that the $image-path can be 
altered dynamically -->
+        <style type="text/css">
+            body {
+                margin: 0px;
+                padding: 0px;
+                font-family: "Lucida Grande","Lucida Sans","Microsoft Sans 
Serif","Lucida Sans Unicode",verdana,sans-serif,"trebuchet ms";
+                font-size: 11px;
+            }
+
+            p { }
+            td { }
+            a:link { }
+            a:visited { }
+            a:hover { }
+            a:active { }
+            a img {
+                border: 0px;
+            }
+
+            /* header styles */
+            div#header {
+                height: 70px;
+                border-bottom: solid 1px #F47B20;
+            }
+            div#header h1 {
+                margin-top: 10px;
+                margin-bottom: 0px;
+                margin-left: 0px;
+                margin-right: 0px;
+                padding-left: 40px;
+                padding-top: 15px;
+                padding-right: 0px;
+                padding-bottom: 0px;
+                font-size: 24px;
+                font-weight: bold;
+            }
+            div#logo {
+                padding-top: 5px;
+                padding-right: 25px;
+                float: right;
+            }
+            div#logo a img {
+                border: 0px;
+            }
+
+            /* body styles */
+            div#body {
+                background-image: url(<xsl:value-of 
select="$image-path"/>header-bg.gif);
+                background-position: top left;
+                background-repeat: no-repeat;
+            }
+            div#intro {
+                padding-left: 40px;
+                padding-top: 10px;
+                width: 90%;
+            }
+
+            /* footer styles */
+            div#footer {
+                margin-top: 30px;
+                clear: both;
+                height: 19px;
+                background-color: #ccc;
+                border-top: solid 1px #F47B20;
+                padding-left: 20px;
+                padding-top: 3px;
+                font-size: 11px;
+            }
+
+            /* middle styles */
+            div#middle {
+                margin-left: 40px;
+                margin-right: 50px;
+                margin-right: 20px;
+                margin-bottom: 0px;
+            }
+
+            div.subtitle {
+                margin-top:.5em;
+                font-weight:bold;
+                font-size:140%;
+            }
+
+            /* operation table styles */
+            table#operationsTable {
+                margin:.5em .5em .5em 1em
+            }
+
+            table#operationsTable tr.operation {
+                vertical-align:top;
+                padding-top:3em
+            }
+            table#operationsTable td.operationName {
+                white-space:nowrap;
+                padding-right:1.5em;
+                font-weight:bold;
+                font-size:11px;
+            }
+            table#operationsTable td {
+                font-size:11px;
+            }
+
+            table#operationsTable table.params {
+                margin: .5em 0em 1.5em 0em
+            }
+            table#operationsTable table.params th {
+                text-align:left;
+                font-size:11px;
+            }
+            table#operationsTable table.params td.parameter,
+            table#operationsTable table.params td.return {
+                text-align:right;
+                padding-right: 1em;
+                padding-left: 2em;
+                border-right: 1px solid #F47B20;
+            }
+            table#operationsTable table.params td.return {
+                font-style:italic;
+            }
+            table#operationsTable table.params td.type {
+                padding-left:1em;
+                font-style:italic
+            }
+            table#operationsTable table.params td.type .enumeration {
+                font-style:normal
+            }
+        </style>
+    </xsl:template>
 
 </xsl:stylesheet>
\ No newline at end of file

_______________________________________________
Commons-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/commons-dev

Reply via email to