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

📄 wsdl-viewer.xsl

📁 一个XML文件的两种解析方法
💻 XSL
📖 第 1 页 / 共 5 页
字号:
			</xsl:apply-templates>
		</xsl:if>
		<xsl:apply-templates select="*"
			mode="operations.message.part">
			<xsl:with-param name="anti.recursion"
				select="$anti.recursion" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template match="xsd:union" mode="operations.message.part">
		<xsl:call-template name="process-union">
			<xsl:with-param name="set" select="@memberTypes" />
		</xsl:call-template>
	</xsl:template>
	<xsl:template name="process-union">
		<xsl:param name="set" />
		<xsl:if test="$set">
			<xsl:variable name="item"
				select="substring-before($set, ' ')" />
			<xsl:variable name="the-rest"
				select="substring-after($set, ' ')" />

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

			<xsl:call-template name="render-type">
				<xsl:with-param name="type-local-name"
					select="$type-name" />
			</xsl:call-template>

			<xsl:call-template name="process-union">
				<xsl:with-param name="set" select="$the-rest" />
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template match="xsd:sequence" mode="operations.message.part">
		<xsl:param name="anti.recursion" />
		<ul type="square">
			<xsl:apply-templates select="*"
				mode="operations.message.part">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
			</xsl:apply-templates>
		</ul>
	</xsl:template>
	<xsl:template match="xsd:all" mode="operations.message.part">
		<xsl:param name="anti.recursion" />
		<ul type="diamond">
			<xsl:apply-templates select="*"
				mode="operations.message.part">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
			</xsl:apply-templates>
		</ul>
	</xsl:template>
	<xsl:template match="xsd:any" mode="operations.message.part">
		<xsl:param name="anti.recursion" />
		<ul type="box">
			<xsl:apply-templates select="*"
				mode="operations.message.part">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
			</xsl:apply-templates>
		</ul>
	</xsl:template>
	<xsl:template match="xsd:element[parent::xsd:schema]"
		mode="operations.message.part">
		<xsl:param name="anti.recursion" />
		<xsl:variable name="recursion.label"
			select="concat('[', @name, ']')" />
		<xsl:variable name="recursion.test">
			<xsl:call-template name="recursion.should.continue">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
				<xsl:with-param name="recursion.label"
					select="$recursion.label" />
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="string-length($recursion.test) != 0">
				<xsl:variable name="type-name">
					<xsl:call-template name="xsd.element-type" />
				</xsl:variable>
				<xsl:variable name="elem-type"
					select="$consolidated-xsd[generate-id() != generate-id(current()) and $type-name and @name=$type-name and contains(local-name(), 'Type')][1]" />

				<xsl:if test="$type-name != @name">
					<xsl:apply-templates select="$elem-type"
						mode="operations.message.part">
						<xsl:with-param name="anti.recursion"
							select="concat($anti.recursion, $recursion.label)" />
					</xsl:apply-templates>

					<xsl:if test="not($elem-type)">
						<xsl:call-template name="render-type">
							<xsl:with-param name="type-local-name"
								select="$type-name" />
						</xsl:call-template>
					</xsl:if>

					<xsl:apply-templates select="*"
						mode="operations.message.part">
						<xsl:with-param name="anti.recursion"
							select="concat($anti.recursion, $recursion.label)" />
					</xsl:apply-templates>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<small style="color:blue">
					<xsl:value-of select="$RECURSIVE" />
				</small>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>
	<xsl:template match="xsd:element | xsd:attribute"
		mode="operations.message.part">
		<xsl:param name="anti.recursion" />
		<!--
			<xsl:variable name="recursion.label" select="concat('[', @name, ']')"/>
		-->
		<li>
			<xsl:variable name="local-ref"
				select="concat(@name, substring-after(@ref, ':'))" />
			<xsl:variable name="elem-name">
				<xsl:choose>
					<xsl:when test="@name">
						<xsl:value-of select="@name" />
					</xsl:when>
					<xsl:when test="$local-ref">
						<xsl:value-of select="$local-ref" />
					</xsl:when>
					<xsl:when test="@ref">
						<xsl:value-of select="@ref" />
					</xsl:when>
					<xsl:otherwise>anonymous</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<xsl:value-of select="$elem-name" />

			<xsl:variable name="type-name">
				<xsl:call-template name="xsd.element-type" />
			</xsl:variable>

			<xsl:call-template name="render-type">
				<xsl:with-param name="type-local-name"
					select="$type-name" />
			</xsl:call-template>

			<xsl:variable name="elem-type"
				select="$consolidated-xsd[@name = $type-name and contains(local-name(), 'Type')][1]" />
			<xsl:apply-templates select="$elem-type | *"
				mode="operations.message.part">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
			</xsl:apply-templates>
		</li>
	</xsl:template>
	<xsl:template
		match="xsd:attribute[ @*[local-name() = 'arrayType'] ]"
		mode="operations.message.part">
		<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:variable name="recursion.label"
			select="concat('[', $type-local-name, ']')" />
		<xsl:variable name="recursion.test">
			<xsl:call-template name="recursion.should.continue">
				<xsl:with-param name="anti.recursion"
					select="$anti.recursion" />
				<xsl:with-param name="recursion.label"
					select="$recursion.label" />
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="string-length($recursion.test) != 0">
				<xsl:apply-templates select="$array-type"
					mode="operations.message.part">
					<xsl:with-param name="anti.recursion"
						select="concat($anti.recursion, $recursion.label)" />
				</xsl:apply-templates>
			</xsl:when>
			<xsl:otherwise>
				<small style="color:blue">
					<xsl:value-of select="$RECURSIVE" />
				</small>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="xsd.element-type">
		<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="type-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>undefined</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:value-of select="$type-name" />
	</xsl:template>
	<xsl:template match="xsd:documentation"
		mode="operations.message.part">
		<div style="color:green">
			<xsl:value-of select="." disable-output-escaping="yes" />
		</div>
	</xsl:template>
	<xsl:template name="render-type">
		<xsl:param name="anti.recursion" />
		<xsl:param name="type-local-name" />

		<xsl:if test="$ENABLE-OPERATIONS-TYPE">
			<xsl:variable name="properties">
				<xsl:if
					test="self::xsd:element | self::xsd:attribute[parent::xsd:complexType]">
					<xsl:variable name="min">
						<xsl:if test="@minOccurs = '0'">
							optional
						</xsl:if>
					</xsl:variable>
					<xsl:variable name="max">
						<xsl:if test="@maxOccurs = 'unbounded'">
							unbounded
						</xsl:if>
					</xsl:variable>
					<xsl:variable name="nillable">
						<xsl:if test="@nillable">nillable</xsl:if>
					</xsl:variable>

					<xsl:if
						test="(string-length($min) + string-length($max) + string-length($nillable) + string-length(@use)) &gt; 0">
						<xsl:text> - </xsl:text>
						<xsl:value-of select="$min" />
						<xsl:if
							test="string-length($min) and string-length($max)">
							<xsl:text>, </xsl:text>
						</xsl:if>
						<xsl:value-of select="$max" />
						<xsl:if
							test="(string-length($min) + string-length($max)) &gt; 0 and string-length($nillable)">
							<xsl:text>, </xsl:text>
						</xsl:if>
						<xsl:value-of select="$nillable" />
						<xsl:if
							test="(string-length($min) + string-length($max) + string-length($nillable)) &gt; 0 and string-length(@use)">
							<xsl:text>, </xsl:text>
						</xsl:if>
						<xsl:value-of select="@use" />
						<xsl:text>; </xsl:text>
					</xsl:if>
				</xsl:if>
			</xsl:variable>

			<xsl:variable name="recursion.label"
				select="concat('[', $type-local-name, ']')" />
			<xsl:variable name="recursion.test">
				<xsl:call-template name="recursion.should.continue">
					<xsl:with-param name="anti.recursion"
						select="$anti.recursion" />
					<xsl:with-param name="recursion.label"
						select="$recursion.label" />
					<xsl:with-param name="recursion.count"
						select="$ANTIRECURSION-DEPTH" />
				</xsl:call-template>
			</xsl:variable>

			<xsl:if test="string-length($recursion.test) != 0">
				<small style="color:blue">
					<xsl:value-of select="$properties" />
					<xsl:variable name="elem-type"
						select="$consolidated-xsd[@name = $type-local-name and (not(contains(local-name(current()), 'element')) or contains(local-name(), 'Type'))][1]" />
					<xsl:if
						test="string-length($type-local-name) &gt; 0">
						<xsl:call-template
							name="render-type.write-name">
							<xsl:with-param name="type-local-name"
								select="$type-local-name" />
						</xsl:call-template>
					</xsl:if>

					<xsl:choose>
						<xsl:when test="$elem-type">

							<xsl:apply-templates select="$elem-type"
								mode="render-type">
								<xsl:with-param name="anti.recursion"
									select="concat($anti.recursion, $recursion.label)" />
							</xsl:apply-templates>
						</xsl:when>
						<xsl:otherwise>

							<xsl:apply-templates select="*"
								mode="render-type">
								<xsl:with-param name="anti.recursion"
									select="concat($anti.recursion, $recursion.label)" />
							</xsl:apply-templates>
						</xsl:otherwise>
					</xsl:choose>
				</small>
			</xsl:if>
		</xsl:if>
	</xsl:template>
	<xsl:template name="render-type.write-name">
		<xsl:param name="type-local-name" />
		<xsl:text> type </xsl:text>
		<big>
			<i>
				<xsl:choose>
					<xsl:when test="$type-local-name">
						<xsl:value-of select="$type-local-name" />
					</xsl:when>
					<xsl:otherwise>undefined</xsl:otherwise>
				</xsl:choose>
			</i>
		</big>
	</xsl:template>
	<xsl:template match="*" mode="render-type" />
	<xsl:template
		match="xsd:element | xsd:complexType | xsd:simpleType | xsd:complexContent"
		mode="render-type">
		<xsl:param name="anti.recursion" />
		<xsl:apply-templates select="*" mode="render-type">
			<xsl:with-param name="anti.recursion"
				select="$anti.recursion" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template match="xsd:restriction[ parent::xsd:simpleType ]"
		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:text> - </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:text> with </xsl:text>
		<xsl:value-of select="local-name()" />
		<xsl:apply-templates select="*" mode="render-type">
			<xsl:with-param name="anti.recursion"
				select="$anti.recursion" />
		</xsl:apply-templates>
	</xsl:template>
	<xsl:template
		match="xsd:simpleType/xsd:restriction/xsd:*[not(self::xsd:enumeration)]"
		mode="render-type">
		<xsl:text> </xsl:text>

⌨️ 快捷键说明

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