[xsl] Transforming cascading included schemas

Subject: [xsl] Transforming cascading included schemas
From: Jean Lemons <jkslagle@xxxxxxxxxxxxx>
Date: Mon, 30 Sep 2002 23:02:58 -0500
I need to produce documentation in HTML for web services defined in WSDL. The schema for these are in separate XSD files associated with the WSDL file using xsd:include or xsd import. I need to access the information in the schema to document the format information for the web service messages.

My problem is that the includes/imports for the needed schema are not all in the primary source document. There are includes/imports in the schema documents as well. Example:

Source wsdl SSS.wsdl:
<wsdl:definitions name="SSS" ...>
<xsd:include schemaLocation="AAA.xsd"/>
<wsdl:message name="MSG1">
<wsdl:part name="part1" type="type1"/>
<wsdl:portType name="SSSPortType">
<wsdl:operation name="SSS">
<wsdl:input message="MSG1"/>

Schema AAA.xsd
... >
<xsd:include schemaLocation="BBB.xsd"/>
<xsd:element name="type1">
<xsd:element ref="type2"/>

Schema BBB.xsd
... >
<xsd:element name="type2">
<xsd:restriction base="xsd:string">
<xsd:length value="5"/>

Desired output for the message information is along the lines of:
Operation Description
SSS Blah Blah Blah
Part part1
Type Name Type Length Min Max
Type1 Type2
Type2 String 5

The relevant XSLT that I have for this (I think) is:

<!-- Key: types -->
<xsl:key name="msgType" match="//xsd:schema//*" use="@name"/>
<!-- Handle Include -->
<xsl:template match="//xsd:include">
<xsl:apply-templates select="document(@schemaLocation)"/>

My confusion is in how to grab the document names so I can access the key information. (I'm also not 100% sure I am getting the keys). I need this to run on multiple WSDL files, so before the time of transformation, I do not know the names of the schema files, how many or how many levels of them there are, or which types are in which schema files. Since the includes are not all in the source file, I can't figure out how to create a variable with the documents as suggested in Re: AW: document() and position() <http://sources.redhat.com/ml/xsl-list/2000-07/msg00820.html> from July 2000 (http://sources.redhat.com/ml/xsl-list/2000-07/msg00820.html) for the new document context for each document in a for-each as was suggested in Re: [xsl] xsl:key and document() <http://www.biglist.com/lists/xsl-list/archives/200101/msg00217.html> from January, 2001 (http://www.biglist.com/lists/xsl-list/archives/200101/msg00217.html).

I'm using the Xalan-Java version 2.4.D1 processor.

I hope this makes sense. I'd appreciate any help. I'm a bit new to XML/XSL/Xpath/etc.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread