complexTypes に他の complexTypes である要素が頻繁に含まれる場合、ドキュメンテーションの目的で XSL を使用して解析しようとしている XSD ドキュメントがあります。可能であれば、これらの複合型要素の内容をコンテナーの横に表示したいと考えています。これが私が取り組んでいることの簡単な例です:
<xs:complexType name="S">
<xs:sequence>
<xs:element name="A" type="X"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="X">
<xs:sequence>
<xs:element name="F"/>
<xs:element name="G"/>
<xs:element name="H"/>
</xs:sequence>
</xs:complexType>
上記を次のように表示するにはどうすればよいですか?
事前に助けてくれてありがとう!
追加された例:
<xsl:for-each select="*">
<xsl:choose>
<!-- call template without param -->
<xsl:when test="name() = 'xs:complexType'">
<xsl:value-of select="@name"/>
<xsl:text> contains </xsl:text>
<xsl:call-template name="top"/>
<xsl:text>
</xsl:text>
</xsl:when>
<!-- for contained elements with types -->
<xsl:when test="@type != '' and name() = 'xs:element' and $typeToLocate = ''">
<xsl:value-of select="@name"/>
<xsl:text> of type </xsl:text>
<xsl:value-of select="@type"/>
<xsl:text>(which contains: </xsl:text>
<!--
point at which i want processor to return to root, locate the
indicated complex type, output its contents then continue going
through schema.
-->
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="@type"/>
</xsl:call-template>
<xsl:text>)</xsl:text>
</xsl:when>
<!-- when type is located, send it to signal proper output -->
<xsl:when test="$typeToLocate != '' and $typeToLocate = @name">
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for elements contained in indicated type -->
<xsl:when test="$typeToLocate != '' and name() = 'xs:element'">
<xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for continuing through non-content elements under found type -->
<xsl:when test="$typeToLocate != ''">
<xsl:call-template name="top">
<xsl:with-param name="typeToLocate" select="$typeToLocate"/>
</xsl:call-template>
</xsl:when>
<!-- for ignoring non-content elements during normal processing -->
<xsl:otherwise>
<xsl:call-template name="top"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>