⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsdl-viewer.xsl

📁 一个XML文件的两种解析方法
💻 XSL
📖 第 1 页 / 共 5 页
字号:
	<xsl:template name="about.detail">
		<xsl:param name="version" />
		<div>
			This page has been generated by
			<big>wsdl-viewer.xsl</big>
			, version
			<xsl:value-of select="$version" />
			<br />
			Author:
			<a href="http://tomi.vanek.sk/">tomi vanek</a>
			<br />
			Download at
			<a href="http://tomi.vanek.sk/xml/wsdl-viewer.xsl">
				http://tomi.vanek.sk/xml/wsdl-viewer.xsl
			</a>
			.
			<br />
			<br />
			The transformation was inspired by the article
			<br />
			Uche Ogbuji:
			<a
				href="http://www-106.ibm.com/developerworks/library/ws-trans/index.html">
				WSDL processing with XSLT
			</a>
			<br />
		</div>
	</xsl:template>
	<xsl:template name="processor-info.render">
		<xsl:text>
</xsl:text>
		<xsl:text>This document was generated by </xsl:text>
		<a href="{system-property('xsl:vendor-url')}">
			<xsl:value-of select="system-property('xsl:vendor')" />
		</a>
		<xsl:text> XSLT engine.
</xsl:text>

		<xsl:text>The engine processed the WSDL in XSLT </xsl:text>
		<xsl:value-of
			select="format-number(system-property('xsl:version'), '#.0')" />
		<xsl:text> compliant mode.
</xsl:text>

	</xsl:template>

	<!--
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		End of included transformation: wsdl-viewer-util.xsl
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-->



	<!--
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		Begin of included transformation: wsdl-viewer-service.xsl
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-->
	<xsl:template match="ws:service|ws2:service" mode="service-start">
		<div class="indent">
			<div class="label">Target Namespace:</div>
			<div class="value">
				<xsl:value-of
					select="$consolidated-wsdl/@targetNamespace" />
			</div>
			<xsl:apply-templates
				select="*[local-name(.) = 'documentation']"
				mode="documentation.render" />
			<xsl:apply-templates select="ws:port|ws2:endpoint"
				mode="service" />
		</div>
	</xsl:template>
	<xsl:template match="ws2:endpoint" mode="service">
		<xsl:variable name="binding-name">
			<xsl:apply-templates select="@binding"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:variable name="binding"
			select="$consolidated-wsdl/ws2:binding[@name = $binding-name]" />

		<xsl:variable name="binding-type" select="$binding/@type" />
		<xsl:variable name="binding-protocol"
			select="$binding/@*[local-name() = 'protocol']" />
		<xsl:variable name="protocol">
			<xsl:choose>
				<xsl:when
					test="starts-with($binding-type, 'http://schemas.xmlsoap.org/wsdl/soap')">
					SOAP 1.1
				</xsl:when>
				<xsl:when
					test="starts-with($binding-type, 'http://www.w3.org/2005/08/wsdl/soap')">
					SOAP 1.2
				</xsl:when>
				<xsl:when
					test="starts-with($binding-type, 'http://schemas.xmlsoap.org/wsdl/mime')">
					MIME
				</xsl:when>
				<xsl:when
					test="starts-with($binding-type, 'http://schemas.xmlsoap.org/wsdl/http')">
					HTTP
				</xsl:when>
				<xsl:otherwise>Unknown</xsl:otherwise>
			</xsl:choose>

			<!-- TODO: Add all bindings to transport protocols -->
			<xsl:choose>
				<xsl:when
					test="starts-with($binding-protocol, 'http://www.w3.org/2003/05/soap/bindings/HTTP')">
					over HTTP
				</xsl:when>
				<xsl:otherwise />
			</xsl:choose>
		</xsl:variable>

		<div class="label">Location:</div>
		<div class="value">
			<xsl:value-of select="@address" />
		</div>

		<div class="label">Protocol:</div>
		<div class="value">
			<xsl:value-of select="$protocol" />
		</div>

		<xsl:apply-templates select="$binding" mode="service" />

		<xsl:variable name="iface-name">
			<xsl:apply-templates select="../@interface"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws2:interface[@name = $iface-name]"
			mode="service" />

	</xsl:template>
	<xsl:template match="ws2:interface" mode="service">
		<h3>
			Interface
			<b>
				<xsl:value-of select="@name" />
			</b>
			<xsl:if test="$ENABLE-LINK">
				<xsl:text> </xsl:text>
				<small>
					<xsl:if test="$ENABLE-OPERATIONS-PARAGRAPH">
						<a class="local"
							href="#{concat($PORT-PREFIX, generate-id(.))}">
							<xsl:value-of select="$PORT-TYPE-TEXT" />
						</a>
					</xsl:if>
					<xsl:call-template name="render.source-code-link" />
				</small>
			</xsl:if>
		</h3>

		<div class="label">Operations:</div>
		<div class="value">
			<xsl:text>
</xsl:text>
			<ol style="line-height: 180%;">
				<xsl:apply-templates select="ws2:operation"
					mode="service">
					<xsl:sort select="@name" />
				</xsl:apply-templates>
			</ol>
		</div>
	</xsl:template>
	<xsl:template match="ws:port" mode="service">
		<xsl:variable name="binding-name">
			<xsl:apply-templates select="@binding"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:variable name="binding"
			select="$consolidated-wsdl/ws:binding[@name = $binding-name]" />

		<xsl:variable name="binding-uri"
			select="namespace-uri( $binding/*[local-name() = 'binding'] )" />
		<xsl:variable name="protocol">
			<xsl:choose>
				<xsl:when
					test="starts-with($binding-uri, 'http://schemas.xmlsoap.org/wsdl/soap')">
					SOAP
				</xsl:when>
				<xsl:when
					test="starts-with($binding-uri, 'http://schemas.xmlsoap.org/wsdl/mime')">
					MIME
				</xsl:when>
				<xsl:when
					test="starts-with($binding-uri, 'http://schemas.xmlsoap.org/wsdl/http')">
					HTTP
				</xsl:when>
				<xsl:otherwise>unknown</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="port-type-name">
			<xsl:apply-templates select="$binding/@type"
				mode="qname.normalized" />
		</xsl:variable>

		<xsl:variable name="port-type"
			select="$consolidated-wsdl/ws:portType[@name = $port-type-name]" />


		<h3>
			Port
			<b>
				<xsl:value-of select="@name" />
			</b>
			<xsl:if test="$ENABLE-LINK">
				<xsl:text> </xsl:text>
				<small>
					<xsl:if test="$ENABLE-OPERATIONS-PARAGRAPH">
						<a class="local"
							href="#{concat($PORT-PREFIX, generate-id($port-type))}">
							<xsl:value-of select="$PORT-TYPE-TEXT" />
						</a>
					</xsl:if>
					<xsl:call-template name="render.source-code-link" />
				</small>
			</xsl:if>
		</h3>

		<div class="label">Location:</div>
		<div class="value">
			<xsl:value-of
				select="*[local-name() = 'address']/@location" />
		</div>

		<div class="label">Protocol:</div>
		<div class="value">
			<xsl:value-of select="$protocol" />
		</div>

		<xsl:apply-templates select="$binding" mode="service" />

		<div class="label">Operations:</div>
		<div class="value">
			<xsl:text>
</xsl:text>
			<ol style="line-height: 180%;">
				<xsl:apply-templates
					select="$consolidated-wsdl/ws:portType[@name = $port-type-name]/ws:operation"
					mode="service">
					<xsl:sort select="@name" />
				</xsl:apply-templates>
			</ol>
		</div>
	</xsl:template>
	<xsl:template match="ws:operation|ws2:operation" mode="service">
		<li>
			<big>
				<i>
					<xsl:value-of select="@name" />
				</i>
			</big>
			<xsl:if test="$ENABLE-LINK">
				<xsl:if test="$ENABLE-OPERATIONS-PARAGRAPH">
					<a class="local"
						href="{concat('#', $OPERATIONS-PREFIX, generate-id(.))}">
						Detail
					</a>
				</xsl:if>
				<xsl:call-template name="render.source-code-link" />
			</xsl:if>
		</li>
	</xsl:template>
	<xsl:template match="ws:binding|ws2:binding" mode="service">
		<xsl:variable name="real-binding"
			select="*[local-name() = 'binding']|self::ws2:*" />

		<xsl:if test="$real-binding/@style">
			<div class="label">Default style:</div>
			<div class="value">
				<xsl:value-of select="$real-binding/@style" />
			</div>
		</xsl:if>


		<xsl:if
			test="$real-binding/@transport|$real-binding/*[local-name() = 'protocol']">
			<xsl:variable name="protocol"
				select="concat($real-binding/@transport, $real-binding/*[local-name() = 'protocol'])" />
			<div class="label">Transport protocol:</div>
			<div class="value">
				<xsl:choose>
					<xsl:when
						test="$protocol = 'http://schemas.xmlsoap.org/soap/http'">
						SOAP over HTTP
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="$protocol" />
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</xsl:if>

		<xsl:if test="$real-binding/@verb">
			<div class="label">Default method:</div>
			<div class="value">
				<xsl:value-of select="$real-binding/@verb" />
			</div>
		</xsl:if>
	</xsl:template>

	<!--
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		End of included transformation: wsdl-viewer-service.xsl
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-->



	<!--
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		Begin of included transformation: wsdl-viewer-operations.xsl
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-->
	<xsl:template match="ws2:interface" mode="operations">
		<xsl:if test="$ENABLE-PORTTYPE-NAME">
			<h3>
				<a name="{concat($IFACE-PREFIX, generate-id(.))}">
					<xsl:value-of select="$IFACE-TEXT" />
					<xsl:text>
</xsl:text>
					<b>
						<xsl:value-of select="@name" />
					</b>
				</a>
				<xsl:call-template name="render.source-code-link" />
			</h3>
		</xsl:if>

		<ol>
			<xsl:apply-templates select="ws2:operation"
				mode="operations">
				<xsl:sort select="@name" />
			</xsl:apply-templates>
		</ol>
	</xsl:template>
	<xsl:template match="ws2:operation" mode="operations">
		<xsl:variable name="binding-info"
			select="$consolidated-wsdl/ws2:binding[@interface = current()/../@name or substring-after(@interface, ':') = current()/../@name]/ws2:operation[@ref = current()/@name or substring-after(@ref, ':') = current()/@name]" />
		<li>
			<xsl:if test="position() != last()">
				<xsl:attribute name="class">operation</xsl:attribute>
			</xsl:if>
			<big>
				<b>
					<a
						name="{concat($OPERATIONS-PREFIX, generate-id(.))}">
						<xsl:value-of select="@name" />
					</a>
				</b>
			</big>
			<div class="value">
				<xsl:text>
</xsl:text>
				<xsl:call-template name="render.source-code-link" />
			</div>
			<xsl:apply-templates select="ws2:documentation"
				mode="documentation.render" />

			<xsl:if test="$ENABLE-STYLEOPTYPEPATH">
				<!-- TODO: add the operation attributes - according the WSDL 2.0 spec. -->
			</xsl:if>
			<xsl:apply-templates
				select="ws2:input|ws2:output|../ws2:fault[@name = ws2:infault/@ref or @name = ws2:outfault/@ref]"
				mode="operations.message">
				<xsl:with-param name="binding-data"
					select="$binding-info" />
			</xsl:apply-templates>
		</li>
	</xsl:template>
	<xsl:template match="ws2:input|ws2:output|ws2:fault"
		mode="operations.message">
		<xsl:param name="binding-data" />
		<xsl:if test="$ENABLE-INOUTFAULT">
			<div class="label">
				<xsl:value-of
					select="concat(translate(substring(local-name(.), 1, 1), 'abcdefghijklmnoprstuvwxyz', 'ABCDEFGHIJKLMNOPRSTUVWXYZ'), substring(local-name(.), 2), ':')" />
			</div>

			<div class="value">
				<xsl:variable name="type-name">
					<xsl:apply-templates select="@element"
						mode="qname.normalized" />
				</xsl:variable>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -