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" ...>
<wsdl:types>
<xsd:schema>
<xsd:include schemaLocation="AAA.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="MSG1">
<wsdl:part name="part1" type="type1"/>
</wsdl:message>
...
<wsdl:portType name="SSSPortType">
<wsdl:operation name="SSS">
<wsdl:input message="MSG1"/>
...
</wsdl:operation>
</wsdl:portType>
...
</wsdl:definitions>
Schema AAA.xsd
…
<xsd:schema
... >
<xsd:include schemaLocation="BBB.xsd"/>
<xsd:element name="type1">
<xsd:complexType>
<xsd:all>
<xsd:element ref="type2"/>
…
</xsd:all>
</xsd:complexType>
</xsd:element>
…
</xsd:schema>
Schema BBB.xsd
…
<xsd:schema
... >
<xsd:element name="type2">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:length value="5"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
...
</xsd:schema>
Desired output for the message information is along the lines of:
Operation Description
SSS Blah Blah Blah
INPUT MSG: MSG1
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)"/>
<xsl:apply-templates/>
</xsl:template>
...
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.
Thanks,
Jeanie
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list