On the other hand not all tooling will handle referenced schemas and it is necessary to embed the schema in the WSDL.
This XSLT transformation will turn a WSDL containing references to other schemas into an equivalent WSDL that embeds those schemas inline.
<?xml version="1.0"?> <!-- This stylesheet will embed any schemas referenced with an 'import' element so an equivalent standalone WSDL is created. This is necessary for tools that don't work with referenced schemas. --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsl:output method="xml" indent="no"/> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="wsdl:types"> <xsl:copy> <xsl:apply-templates select="xsd:schema/xsd:import" mode="embed" /> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="xsd:import"> <xsd:import> <xsl:attribute name="namespace"><xsl:value-of select="@namespace" /></xsl:attribute> </xsd:import> </xsl:template> <xsl:template match="xsd:import" mode="embed"> <xsl:apply-templates select="document(@schemaLocation)" /> </xsl:template> </xsl:stylesheet> |
2 comments:
I just bothered to read that through in detail, that's actually reall cool
hi, it works fine with one imported schema but doesn't if it has another imported schema
Post a Comment