Expanding XSD complex element types with XSL?

Kolega

New Member
I've got an XSD document I'm trying to parse with XSL for documentation purposes where the complexTypes frequently contain elements that are other complexTypes. I'd like to display the contents of these complex type elements next to their containers if possible. Here's a simple example of what I'm working with:\[code\]<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>\[/code\]How would I get the above to show as something like: "S contains A of type X(which contains F, G, and H)"?Thanks for any help in advance!Added example: \[code\] <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>\[/code\]
 
Back
Top