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

📄 wsdl-viewer.xsl

📁 一个XML文件的两种解析方法
💻 XSL
📖 第 1 页 / 共 5 页
字号:
		<xsl:value-of select="local-name()" />
		<xsl:text>(</xsl:text>
		<xsl:value-of select="@value" />
		<xsl:text>)</xsl:text>
	</xsl:template>
	<xsl:template match="xsd:restriction | xsd:extension"
		mode="render-type">
		<xsl:param name="anti.recursion" />
		<xsl:variable name="type-local-name"
			select="substring-after(@base, ':')" />
		<xsl:variable name="type-name">
			<xsl:choose>
				<xsl:when test="$type-local-name">
					<xsl:value-of select="$type-local-name" />
				</xsl:when>
				<xsl:when test="@base">
					<xsl:value-of select="@base" />
				</xsl:when>
				<xsl:otherwise>undefined</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="base-type"
			select="$consolidated-xsd[@name = $type-name][1]" />
		<xsl:variable name="abstract">
			<xsl:if test="$base-type/@abstract">abstract</xsl:if>
		</xsl:variable>

		<xsl:if test="not($type-name = 'Array')">
			<xsl:value-of
				select="concat(' - ', local-name(), ' of ', $abstract)" />
			<xsl:call-template name="render-type.write-name">
				<xsl:with-param name="type-local-name"
					select="$type-name" />
			</xsl:call-template>
		</xsl:if>

		<xsl:apply-templates select="$base-type | *"
			mode="render-type">
			<xsl:with-param name="anti.recursion"
				select="$anti.recursion" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template
		match="xsd:attribute[ @*[local-name() = 'arrayType'] ]"
		mode="render-type">
		<xsl:param name="anti.recursion" />
		<xsl:variable name="array-local-name"
			select="substring-after(@*[local-name() = 'arrayType'], ':')" />
		<xsl:variable name="type-local-name"
			select="substring-before($array-local-name, '[')" />
		<xsl:variable name="array-type"
			select="$consolidated-xsd[@name = $type-local-name][1]" />

		<xsl:text> - array of </xsl:text>
		<xsl:call-template name="render-type.write-name">
			<xsl:with-param name="type-local-name"
				select="$type-local-name" />
		</xsl:call-template>

		<xsl:apply-templates select="$array-type" mode="render-type">
			<xsl:with-param name="anti.recursion"
				select="$anti.recursion" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template match="xsd:enumeration" mode="render-type" />
	<xsl:template
		match="xsd:enumeration[not(preceding-sibling::xsd:enumeration)]"
		mode="render-type">
		<xsl:text> - enum { </xsl:text>
		<xsl:apply-templates
			select="self::* | following-sibling::xsd:enumeration"
			mode="render-type.enum" />
		<xsl:text> }</xsl:text>
	</xsl:template>
	<xsl:template match="xsd:enumeration" mode="render-type.enum">
		<xsl:if test="preceding-sibling::xsd:enumeration">
			<xsl:text>, </xsl:text>
		</xsl:if>
		<xsl:text disable-output-escaping="yes">'</xsl:text>
		<xsl:value-of select="@value" />
		<xsl:text disable-output-escaping="yes">'</xsl:text>
	</xsl:template>

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



	<!--
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
		Begin of included transformation: wsdl-viewer-src.xsl
		@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
	-->
	<xsl:template match="@*" mode="src.import">
		<h2>
			<a name="{concat($SRC-FILE-PREFIX, generate-id(..))}">
				<xsl:choose>
					<xsl:when test="parent::xsd:include">
						Included
					</xsl:when>
					<xsl:otherwise>Imported</xsl:otherwise>
				</xsl:choose>

				<xsl:choose>
					<xsl:when test="name() = 'location'">WSDL</xsl:when>
					<xsl:otherwise>Schema</xsl:otherwise>
				</xsl:choose>
				<i>
					<xsl:value-of select="." />
				</i>
			</a>
		</h2>

		<div class="box">
			<xsl:apply-templates select="document(.)" mode="src" />
		</div>
		<xsl:apply-templates
			select="/*/*[local-name() = 'import'][@location]/@location"
			mode="src.import" />
		<xsl:apply-templates
			select="document(.)//xsd:import[@schemaLocation]/@schemaLocation"
			mode="src.import" />
	</xsl:template>
	<xsl:template match="*" mode="src">
		<div class="xml-element">
			<a name="{concat($SRC-PREFIX, generate-id(.))}">
				<xsl:apply-templates select="." mode="src.link" />
				<xsl:apply-templates select="." mode="src.start-tag" />
			</a>
			<xsl:apply-templates
				select="*|comment()|processing-instruction()|text()[string-length(normalize-space(.)) &gt; 0]"
				mode="src" />
			<xsl:apply-templates select="." mode="src.end-tag" />
		</div>
	</xsl:template>
	<xsl:template match="*" mode="src.start-tag">
		<xsl:call-template name="src.elem">
			<xsl:with-param name="src.elem.end-slash">/</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	<xsl:template
		match="*[*|comment()|processing-instruction()|text()[string-length(normalize-space(.)) &gt; 0]]"
		mode="src.start-tag">
		<xsl:call-template name="src.elem" />
	</xsl:template>
	<xsl:template match="*" mode="src.end-tag" />
	<xsl:template
		match="*[*|comment()|processing-instruction()|text()[string-length(normalize-space(.)) &gt; 0]]"
		mode="src.end-tag">
		<xsl:call-template name="src.elem">
			<xsl:with-param name="src.elem.start-slash">
				/
			</xsl:with-param>
		</xsl:call-template>
	</xsl:template>
	<xsl:template match="*" mode="src.link-attribute">
		<xsl:if test="$ENABLE-LINK">
			<xsl:attribute name="href">
<xsl:value-of select="concat('#', $SRC-PREFIX, generate-id(.))" />
</xsl:attribute>
		</xsl:if>
	</xsl:template>
	<xsl:template
		match="*[local-name() = 'import' or local-name() = 'include'][@location or @schemaLocation]"
		mode="src.link">
		<xsl:if test="$ENABLE-LINK">
			<xsl:attribute name="href">
<xsl:value-of select="concat('#', $SRC-FILE-PREFIX, generate-id(.))" />
</xsl:attribute>
		</xsl:if>
	</xsl:template>
	<xsl:template match="*" mode="src.link" />
	<xsl:template match="ws2:service|ws2:binding" mode="src.link">
		<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="src.link-attribute" />
	</xsl:template>
	<xsl:template match="ws2:endpoint" mode="src.link">
		<xsl:variable name="binding-name">
			<xsl:apply-templates select="@binding"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws2:binding[@name = $binding-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template match="ws2:binding/ws2:operation" mode="src.link">
		<xsl:variable name="operation-name">
			<xsl:apply-templates select="@ref" mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws2:interface/ws2:operation[@name = $operation-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template
		match="ws2:binding/ws2:fault|ws2:interface/ws2:operation/ws2:infault|ws2:interface/ws2:operation/ws2:outfault"
		mode="src.link">
		<xsl:variable name="operation-name">
			<xsl:apply-templates select="@ref" mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws2:interface/ws2:fault[@name = $operation-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template
		match="ws2:interface/ws2:operation/ws2:input|ws2:interface/ws2:operation/ws2:output|ws2:interface/ws2:fault"
		mode="src.link">
		<xsl:variable name="elem-name">
			<xsl:apply-templates select="@element"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-xsd[@name = $elem-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template
		match="ws:operation/ws:input[@message] | ws:operation/ws:output[@message] | ws:operation/ws:fault[@message] | soap:header[ancestor::ws:operation and @message]"
		mode="src.link">
		<xsl:apply-templates
			select="$consolidated-wsdl/ws:message[@name = substring-after( current()/@message, ':' )]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template
		match="ws:operation/ws:input[@message] | ws:operation/ws:output[@message] | ws:operation/ws:fault[@message] | soap:header[ancestor::ws:operation and @message]"
		mode="src.link">
		<xsl:apply-templates
			select="$consolidated-wsdl/ws:message[@name = substring-after( current()/@message, ':' )]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template match="ws:message/ws:part[@element or @type]"
		mode="src.link">
		<xsl:variable name="elem-local-name"
			select="substring-after(@element, ':')" />
		<xsl:variable name="type-local-name"
			select="substring-after(@type, ':')" />
		<xsl:variable name="elem-name">
			<xsl:choose>
				<xsl:when test="$elem-local-name">
					<xsl:value-of select="$elem-local-name" />
				</xsl:when>
				<xsl:when test="$type-local-name">
					<xsl:value-of select="$type-local-name" />
				</xsl:when>
				<xsl:when test="@element">
					<xsl:value-of select="@element" />
				</xsl:when>
				<xsl:when test="@type">
					<xsl:value-of select="@type" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="src.syntax-error" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:apply-templates
			select="$consolidated-xsd[@name = $elem-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template match="ws:service/ws:port[@binding]"
		mode="src.link">
		<xsl:variable name="binding-name">
			<xsl:apply-templates select="@binding"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws:binding[@name = $binding-name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template
		match="ws:operation[@name and parent::ws:binding/@type]"
		mode="src.link">
		<xsl:variable name="type-name">
			<xsl:apply-templates select="../@type"
				mode="qname.normalized" />
		</xsl:variable>
		<xsl:apply-templates
			select="$consolidated-wsdl/ws:portType[@name = $type-name]/ws:operation[@name = current()/@name]"
			mode="src.link-attribute" />
	</xsl:template>
	<xsl:template match="xsd:element[@ref or @type]" mode="src.link">
		<xsl:variable name="ref-or-type">
			<xsl:choose>
				<xsl:when test="@type">
					<xsl:value-of select="@type" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@ref" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>

		<xsl:variable name="type-local-name"
			select="substring-after($ref-or-type, ':')" />
		<xsl:variable name="xsd-name">
			<xsl:choose>
				<xsl:when test="$type-local-name">
					<xsl:value-of select="$type-local-name" />
				</xsl:when>
				<xsl:when test="$ref-or-type">
					<xsl:value-of select="$ref-or-type" />
				</xsl:when>
				<xsl:otherwise />
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="$xsd-name">
			<xsl:variable name="msg"
				select="$consolidated-xsd[@name = $xsd-name and contains(local-name(), 'Type')][1]" />
			<xsl:apply-templates select="$msg"
				mode="src.link-attribute" />
		</xsl:if>
	</xsl:template>
	<xsl:template match="xsd:attribute[contains(@ref, 'arrayType')]"
		mode="src.link">
		<xsl:variable name="att-array-type"
			select="substring-before(@*[local-name() = 'arrayType'], '[]')" />
		<xsl:variable name="xsd-local-name"
			select="substring-after($att-array-type, ':')" />
		<xsl:variable name="xsd-name">
			<xsl:choose>
				<xsl:when test="$xsd-local-name">
					<xsl:value-of select="$xsd-local-name" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="$att-array-type" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:if test="$xsd-name">
			<xsl:variable name="msg"
				select="$consolidated-xsd[@name = $xsd-name][1]" />
			<xsl:apply-templates select="$msg"
				mode="src.link-attribute" />
		</xsl:if>
	</xsl:template>
	<xsl:template match="xsd:extension | xsd:restriction"
		mode="src.link">
		<xsl:variable name="xsd-local-name"
			select="substring-after(@base, ':')" />
		<xsl:variable name="xsd-name">
			<xsl:choose>
				<xsl:when test="$xsd-local-name">
					<xsl:value-of select="$xsd-local-name" />
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@type" />
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="msg"
			select="$consolidated-xsd[@name = $xsd-name][1]" />
		<xsl:apply-templates select="$msg" mode="src.link-attribute" />
	</xsl:template>
	<xsl:template name="src.elem">
		<xsl:param name="src.elem.start-slash" />
		<xsl:param name="src.elem.end-slash" />

		<xsl:value-of
			select="concat('&lt;', $src.elem.start-slash, name(.))"
			disable-output-escaping="no" />
		<xsl:if test="not($src.elem.start-slash)">
			<xsl:apply-templates select="@*" mode="src" />
			<xsl:apply-templates select="." mode="src.namespace" />
		</xsl:if>
		<xsl:value-of select="concat($src.elem.end-slash, '&gt;')"
			disable-output-escaping="no" />
	</xsl:template>
	<xsl:template match="@*" mode="src">
		<xsl:text> </xsl:text>
		<span class="xml-att">
			<xsl:value-of select="concat(name(), '=')" />
			<span class="xml-att-val">
				<xsl:value-of select="concat('&quot;', ., '&quot;')"
					disable-output-escaping="yes" />
			</span>
		</span>
	</xsl:template>
	<xsl:template match="*" mode="src.namespace">
		<xsl:variable name="supports-namespace-

⌨️ 快捷键说明

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