I am using the following xsl to retrieve the schema types from wsdl
<?xml version="1.0" encoding="UTF-8"?><xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//*[local-name()='schema' and namespace-uri()='http://www.w3.org/2001/XMLSchema']">
<xsl:copy-of select="."></xsl:copy-of>
</xsl:template></xsl:transform>
and the following java snippet
tFactory = TransformerFactory.newInstance();
xslSource = new StreamSource("resources/input/wsdl2xsd.xsl");
xmlSource = new StreamSource(wsdlURI.toString());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
outStream = new BufferedOutputStream(byteArrayOutputStream);
transformer = tFactory.newTransformer(xslSource);
transformer.transform(xmlSource, new StreamResult(outStream));
System.out.print(new String(byteArrayOutputStream.toByteArray()));
but for some reason I am getting a lot for empty space with some weird string after the end of my ‘schema’ element?. It works for some wslds though. I tried eBays public wsdl which is huge:
http://developer.ebay.com/webservices/741/eBaySvc.wsdl
which outputs strings after the ‘schema’ element.
Well your current stylesheet code relies on the built-in templates to reach your own template and on that way you might get output from text nodes.
As you don’t seem to want that you can either add
<xsl:template match="text()"/>to your code or you might want a different approach where you simply do e.g.<xsl:template match="/"><xsl:copy-of select="//xs:schema" xmlns:xs="http://www.w3.org/2001/XMLSchema"/></xsl:template>.