diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/ssdt_ohio/tools/ant/wsd2html.xsl	Tue Jun 07 18:06:07 2011 -0400
@@ -0,0 +1,482 @@
+<?xml version="1.0"?>
+<xsl:stylesheet
+		version="1.0"
+		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+		xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+		xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+		xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+		xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+		xmlns:x="http://ssdt.nwoca.org/xml/wsdl2html"
+		xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+	
+	<xsl:output method="html" omit-xml-declaration="yes"/>
+        <xsl:variable name="wsd2htmlVersion" select="'ssdt wsd2html 0.2-0'"/>
+	<xsl:variable name="defaultNamespace">
+		<xsl:for-each select="wsdl:definitions/namespace::*">
+			<xsl:if test="not(name())">
+				<xsl:value-of select="."/>
+			</xsl:if>
+		</xsl:for-each>
+	</xsl:variable>
+	<xsl:variable name="targetNamespace" select="wsdl:definitions/@targetNamespace"/>
+	
+	<xsl:template match="/">
+		<HTML>
+			<HEAD>
+				<TITLE>Web Service Description: <xsl:value-of select="wsdl:definitions/wsdl:service/@name"/>
+				</TITLE>
+				<META HTTP-EQUIV="content-type" content="text/html" charset="UTF-8"/>
+				<STYLE TYPE="text/css">
+BODY {
+	margin-left: 5%;
+	margin-right: 5%;
+}
+H1 {
+ 		background-color: lightgrey;
+}
+H2 {
+ 		background-color: lightgrey;
+}
+H3 {
+ 		background-color: #00CCCC;
+		text-indent: .5em;
+		border: thin solid black;
+		width: 95%;
+}
+P {
+}
+TABLE {
+	border: thin solid black;
+	left-margin: 20em;	
+	width: 80%;
+}
+TD {
+	border: thin solid black;
+	padding: .2em;
+}
+.xml {
+   border: thin dotted blue;
+   padding: .5em;
+   width: 70%;
+   margin-left: 5%;
+}
+.xml UL LI {
+	list-style-image: none;
+	list-style-type: none;
+}
+.attrValue {
+	color: rgb(153, 51, 51);
+        font-weight: bold;
+}
+.attrName {
+	color: rgb(0, 0, 102);
+ }
+.xmlElement {
+	color: black;
+        font-weight: bold;
+}
+
+</STYLE>
+			</HEAD>
+			<BODY>
+				<H1>Web Service Description: <xsl:value-of select="wsdl:definitions/wsdl:service/@name"/>
+				</H1>
+				<h2>Contents</h2>
+				<ul>
+					<li>
+						<a href="#operations">Operations</a>
+					</li>
+					<li>
+						<a href="#messages">Messages</a>
+					</li>
+					<li>
+						<a href="#elements">Elements</a>
+					</li>
+					<li>
+						<a href="#types">Types</a>
+					</li>
+				</ul>
+				<hr/>
+				
+				
+                                <xsl:call-template name="getDoc">
+                                    <xsl:with-param name="doc" select="wsdl:definitions/wsdl:documentation"/>
+                                </xsl:call-template>                                
+                                
+				<HR/>
+				
+				<xsl:apply-templates select="wsdl:definitions/wsdl:service"/>
+				
+				<hr/>
+				
+				<h2>Namespaces:</h2>
+				<table>
+					<tr>
+						<th>Prefix</th>
+						<th>Namespace</th>
+					</tr>
+					<xsl:for-each select="wsdl:definitions/namespace::*">
+					<xsl:sort select="name()"/>
+						<tr>
+							<td>
+								<xsl:choose>
+									<xsl:when test="name()">
+										<xsl:value-of select="name()"/>
+									</xsl:when>
+									<xsl:otherwise>
+										<xsl:text>[Default]</xsl:text>
+									</xsl:otherwise>
+								</xsl:choose>
+							</td>
+							<td>
+								<xsl:value-of select="."/>
+							</td>
+						</tr>
+					</xsl:for-each>
+				</table>
+				
+				<h2>Imported Schemas</h2>
+				
+				<table>
+					<tr>
+						<th>Namespace</th>
+						<th>Location</th>
+					</tr>
+					<xsl:for-each select="wsdl:definitions/wsdl:types/xsd:schema/xsd:import">
+						<tr>
+							<td>
+								<xsl:value-of select="@namespace"/>
+							</td>
+							<td>
+								<xsl:value-of select="@schemaLocation"/>
+							</td>
+						</tr>
+					</xsl:for-each>
+				</table>
+				
+				<HR/>
+				<a name="operations" id="operations"/>
+				<H2>Port Type: <xsl:value-of select="wsdl:definitions/wsdl:portType/@name"/>
+				</H2>
+				<xsl:apply-templates select="wsdl:definitions/wsdl:portType"/>
+				
+				<H2>Operations Detail</H2>
+				<xsl:apply-templates select="wsdl:definitions/wsdl:portType/wsdl:operation">
+				 <xsl:sort select="@name"/>	
+				</xsl:apply-templates>
+				
+				<a name="messages" id="messages"/>
+				<H2>Messsages</H2>
+				<table>
+                                <tr><th>Message</th><th>Parameter</th></tr>
+					<xsl:apply-templates select="wsdl:definitions/wsdl:message">
+					<xsl:sort select="@name"/>
+					</xsl:apply-templates>
+				</table>
+				
+				<a name="elements" id="elements"/>
+				<H2>Elements</H2>
+				<ul>
+				<xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:element" mode="summary">
+				<xsl:sort select="@name"/>
+				</xsl:apply-templates>
+				</ul>
+				<xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:element" mode="detail">
+				<xsl:sort select="@name"/>
+				</xsl:apply-templates>
+	
+				<a name="types" id="types"/>
+				<H2>Types</H2>
+				<ul>
+				<xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:complexType | wsdl:definitions/wsdl:types/xsd:schema/xsd:simpleType"
+					mode="summary">
+					<xsl:sort select="@name"/>
+				</xsl:apply-templates>
+				</ul>
+				<hr/>
+				
+				<xsl:apply-templates select="wsdl:definitions/wsdl:types/xsd:schema/xsd:complexType | wsdl:definitions/wsdl:types/xsd:schema/xsd:simpleType"
+					mode="detail">
+				<xsl:sort select="@name"/>
+				</xsl:apply-templates>
+				
+                <hr/>				
+		<i><font size="-1">Generated by <xsl:value-of select="$wsd2htmlVersion"/></font></i>	
+			</BODY>
+		</HTML>
+	</xsl:template>
+	
+	<xsl:template match="wsdl:operation">
+		<a name="o-{@name}" id="o-{@name}"/>
+		<h3>Operation: <xsl:value-of select="@name"/>
+		</h3>
+                                <xsl:call-template name="getDoc">
+                                    <xsl:with-param name="doc" select="wsdl:documentation"/>
+                                </xsl:call-template>                                
+                <table>
+			<tr>
+				<td>Input</td>
+				<td>
+					<a href="#m-{wsdl:input/@name}">
+						<xsl:value-of select="wsdl:input/@name"/>
+					</a>
+				</td>
+			</tr>
+			<tr>
+				<td>Output</td>
+				<td>
+					<a href="#m-{wsdl:output/@name}">
+						<xsl:value-of select="wsdl:output/@name"/>
+					</a>
+				</td>
+			</tr>
+			<xsl:for-each select="wsdl:fault">
+				<tr>
+					<td>Fault</td>
+					<td>
+                                            <xsl:variable name="typeName">
+                                                    <xsl:call-template name="getQname">
+                                                            <xsl:with-param name="elementName" select="@name"/>
+                                                    </xsl:call-template>
+                                            </xsl:variable>
+                                            <xsl:variable name="anchor">
+                                                    <xsl:call-template name="getAnchor">
+                                                            <xsl:with-param name="anchorText" select="$typeName"/>
+                                                    </xsl:call-template>
+                                            </xsl:variable>                                        
+                                            <a href="#ty-{$anchor}">
+						<xsl:value-of select="@name"/>
+                                            </a>                                        
+					
+					</td>
+					<td>
+                                <xsl:call-template name="getDoc">
+                                    <xsl:with-param name="doc" select="wsdl:documentation"/>
+                                </xsl:call-template>                                
+                                        
+					</td>
+				</tr>
+			</xsl:for-each>
+		</table>
+	
+	</xsl:template>
+	
+	<xsl:template match="wsdl:message">
+		<tr><td>
+                        <a name="m-{@name}" id="m-{@name}"/>
+                        
+			<xsl:value-of select="@name"/>
+                        </td><td>
+                        <xsl:variable name="typeName">
+				<xsl:call-template name="getQname">
+					<xsl:with-param name="elementName" select="wsdl:part/@element"/>
+				</xsl:call-template>
+			</xsl:variable>
+			<xsl:variable name="anchor">
+				<xsl:call-template name="getAnchor">
+					<xsl:with-param name="anchorText" select="$typeName"/>
+				</xsl:call-template>
+			</xsl:variable>
+                        <a href="#e-{$anchor}"> <xsl:value-of select="$typeName"/>
+			</a>
+              </td></tr>
+		
+	</xsl:template>
+	
+	<xsl:template name="getAnchor">
+		<xsl:param name="anchorText"/>
+		<xsl:value-of select="translate(normalize-space($anchorText),':/.[]', '_____')"/>
+	</xsl:template>
+	
+	<xsl:template name="getQname">
+		<xsl:param name="elementName"/>
+		<xsl:choose>
+			<xsl:when test="contains($elementName,':')">
+				[<xsl:value-of select="/wsdl:definitions/namespace::*[name()=substring-before($elementName,':')]"/>]:<xsl:value-of select="substring-after($elementName,':')"/>
+			</xsl:when>
+			<xsl:otherwise>
+				[<xsl:value-of select="$defaultNamespace"/>]:<xsl:value-of select="$elementName"/>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+
+
+
+	
+	<xsl:template match="xsd:element" mode="summary">
+		<xsl:variable name="typeName">
+			<xsl:call-template name="getQname">
+				<xsl:with-param name="elementName" select="@name"/>
+			</xsl:call-template>
+		</xsl:variable>
+		<xsl:variable name="anchor">
+			<xsl:call-template name="getAnchor">
+				<xsl:with-param name="anchorText" select="$typeName"/>
+			</xsl:call-template>
+		</xsl:variable>
+		<li><a href="#e-{$anchor}"><xsl:value-of select="@name"/></a></li>
+	</xsl:template>
+
+	
+	<xsl:template match="xsd:element" mode="detail">
+		
+		<xsl:variable name="typeName">
+			<xsl:call-template name="getQname">
+				<xsl:with-param name="elementName" select="@name"/>
+			</xsl:call-template>
+		</xsl:variable>
+		<xsl:variable name="anchor">
+			<xsl:call-template name="getAnchor">
+				<xsl:with-param name="anchorText" select="$typeName"/>
+			</xsl:call-template>
+		</xsl:variable>
+		
+		<a name="e-{$anchor}" id="e-{$anchor}"/>
+		<h3>
+			<xsl:value-of select="$typeName"/>
+		</h3>
+		<div class="xml">
+			<xsl:call-template name="codeXml"/>
+		</div>
+	</xsl:template>
+
+
+
+	<xsl:template match="xsd:complexType | xsd:simpleType" mode="summary">
+		<xsl:variable name="typeName">
+			<xsl:call-template name="getQname">
+				<xsl:with-param name="elementName" select="@name"/>
+			</xsl:call-template>
+		</xsl:variable>
+		<xsl:variable name="anchor">
+			<xsl:call-template name="getAnchor">
+				<xsl:with-param name="anchorText" select="$typeName"/>
+			</xsl:call-template>
+		</xsl:variable>
+
+        	<li><a href="#ty-{$anchor}"><xsl:value-of select="@name"/></a></li>
+	</xsl:template>
+
+
+	
+	<xsl:template match="xsd:complexType | xsd:simpleType" mode="detail">
+		<xsl:variable name="typeName">
+			<xsl:call-template name="getQname">
+				<xsl:with-param name="elementName" select="@name"/>
+			</xsl:call-template>
+		</xsl:variable>
+		<xsl:variable name="anchor">
+			<xsl:call-template name="getAnchor">
+				<xsl:with-param name="anchorText" select="$typeName"/>
+			</xsl:call-template>
+		</xsl:variable>
+		
+		<a name="ty-{$anchor}" id="ty-{$anchor}"/>
+		<h3>
+			<xsl:value-of select="@name"/>
+		</h3>
+		<div class="xml">
+			<xsl:call-template name="codeXml"/>
+		</div>
+	</xsl:template>
+	
+	<xsl:template match="wsdl:service">
+		<h2>Service Summary: Service: <xsl:value-of select="@name"/>
+		</h2>
+		<xsl:for-each select="wsdl:port">
+			<p>Port name:  <xsl:value-of select="@name"/>
+				<br/>
+          Endpoint URL: <xsl:value-of select="*[local-name()='address']/@location"/>
+				<br/>
+          Binding: <xsl:value-of select="@binding"/>
+			</p>
+		</xsl:for-each>
+	</xsl:template>
+	
+	<xsl:template match="wsdl:portType">
+     Operations:
+     <table>
+     <tr><th>Operation</th>
+				<th>Description</th>
+			</tr>
+			<xsl:for-each select="wsdl:operation">
+				<xsl:sort select="@name"/>
+				<tr>
+					<td>
+						<a href="#o-{@name}">
+							<xsl:value-of select="@name"/>
+						</a>
+					</td>
+					<td>
+						<xsl:call-template name="getShortDescription">
+							<xsl:with-param name="desc" select="wsdl:documentation"/>
+						</xsl:call-template>
+					</td>
+				</tr>
+			</xsl:for-each>
+		</table>
+	</xsl:template>
+	
+	<xsl:template name="getShortDescription">
+		<xsl:param name="desc"/>
+		<xsl:choose>
+			<xsl:when test="contains($desc,'.')">
+				<xsl:value-of select="substring-before($desc,'.')"/>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:value-of select="$desc"/>
+			</xsl:otherwise>
+		</xsl:choose>.
+	</xsl:template>
+	
+	<xsl:template name="codeXml">
+		<xsl:choose>
+			<xsl:when test="name()='xsd:annotation'">
+				<UL>
+					<LI>
+						<P>
+                                <xsl:call-template name="getDoc">
+                                    <xsl:with-param name="doc" select="xsd:documentation"/>
+                                </xsl:call-template>                                
+                                                	</P>
+					</LI>
+				</UL>
+			</xsl:when>
+			<xsl:otherwise>
+				<ul>
+					<li>&lt;<span class="xmlElement"><xsl:value-of select="name()"/></span>
+						<xsl:for-each select="@*"><xsl:text> </xsl:text>
+							<span class="attrName"><xsl:value-of select="name()"/></span>="<span class="attrValue"><xsl:value-of select="."/>
+							</span>"
+						</xsl:for-each>
+						<xsl:choose>
+							<xsl:when test="count(*) = 0">
+								<xsl:text>/&gt;</xsl:text>
+							</xsl:when>
+							<xsl:otherwise>
+					&gt;
+						<xsl:for-each select="*">
+							<xsl:call-template name="codeXml"/>
+								</xsl:for-each>
+						&lt;/<span class="xmlElement"><xsl:value-of select="name()"/></span>&gt;
+					</xsl:otherwise>
+						</xsl:choose>
+					</li>
+				</ul>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+        
+        <xsl:template name="getDoc">
+        <xsl:param name="doc"/>
+        <xsl:choose>
+         <xsl:when test="$doc/*">
+            <xsl:copy-of select="$doc/*"/>     
+        </xsl:when>
+	<xsl:otherwise>
+            <xsl:value-of select="$doc/text()"/>            
+        </xsl:otherwise>			
+        </xsl:choose>
+        </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file