[xsl] How to prevent xmlns attribute in generated output?

Subject: [xsl] How to prevent xmlns attribute in generated output?
From: Michael.Giroux@xxxxxxxx
Date: Mon, 16 May 2005 14:49:12 -0700
Background:
I'm attempting to automate a task that is currently
done by hand.  We have several WSDL fragments
describing message parts for web services.  We have
a tool that produces an xml representation of the
message structures (translate cobol record descriptions
to xml shown below as INPUT XML)

The stylesheet below is attempting to generate a
WSDL <definitions><types> section for a web service WSDL
based on the XML.  The resulting WSDL is included into a
complete WSDL that defines the portType, binding and
service elements.

Problem:
The result is run through WSDL2JAVA to produce the web service
stubs. WSDL2JAVA gets an error:
java.io.IOException: Type {urn:bpel:jiap}syncSubsidyAgreementRequestMsg is
referenced but not defined.

The error is caused by an extra xmlns attribute in the generated
output.

HELP!
I suspect the XSL is missing a key bit, but have no
idea what that might be.  Any help will be appreciated.

Michael Giroux



<!-- INPUT XML DOCUMENT -->
Input XML:
<?xml version='1.0' ?>

<component name='custDemo'>
    <cobolrecord name='syncSubsidyAgreementRequestMsg' >
        <cobolgroup name='syncSubsidyAgreementRequestMsg'>
            <cobolgroup name='subsidyAgreementRequest' >
                <stringitem name='address' />
            </cobolgroup>
        </cobolgroup>
    </cobolrecord>
</component>

<!-- STYLESHEET -->

<?xml version="1.0"?>
<xsl:stylesheet version = '1.0' xmlns="http://schemas.xmlsoap.org/wsdl/";
  xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:tns=
"urn:bpel:jiap"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
  xmlns:xalan="http://xml.apache.org/xslt"; >
  <xsl:output method="xml" indent="yes" xalan:indent-amount="2"/>

  <xsl:template match="/component">
    <definitions targetNamespace="urn:bpel:jiap">
      <xsl:element name="types" >
        <xsl:element name="schema" namespace=
"http://www.w3.org/2001/XMLSchema";>
          <xsl:attribute name="targetNamespace">urn:bpel:jiap
</xsl:attribute>
          <xsl:apply-templates select='cobolrecord'/>
        </xsl:element>
      </xsl:element>
      <xsl:apply-templates select='cobolrecord' mode='message'/>
    </definitions>
  </xsl:template>

  <xsl:template match="cobolrecord">
    <xsl:apply-templates select="cobolgroup"/>
  </xsl:template>

  <xsl:template match="cobolgroup">
    <xsl:element name="complexType">
      <xsl:attribute name="name"><xsl:value-of select="@name"
/></xsl:attribute>
      <sequence>
        <xsl:apply-templates />
      </sequence>
    </xsl:element>
  </xsl:template>

  <xsl:template match="stringitem | decimalitem | packeditem">
    <xsl:element name="element">
      <xsl:attribute name="name"><xsl:value-of select="@name"
/></xsl:attribute>
      <xsl:attribute name="type">xsd:string</xsl:attribute>
    </xsl:element>
  </xsl:template>

  <xsl:template match="cobolrecord" mode="message">
    <xsl:element name="message">
      <xsl:attribute name="name"><xsl:value-of
        select="@name"/>Message</xsl:attribute>
      <xsl:element name="part">
        <xsl:attribute name="name">
          <xsl:value-of select="@name" />
        </xsl:attribute>
        <xsl:attribute name="type">tns:<xsl:value-of
          select="@name"/></xsl:attribute>
      </xsl:element>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

<!--  GENERATED WSDL  -->
Due to xmlns="http://schemas.xmlsoap.org/wsdl/"; in the <complexType>
definition, the <message><part> reference to
tns:syncSubsidyAgreementRequestMsg fails.

<?xml version="1.0" encoding="UTF-8"?>
<definitions
  xmlns="http://schemas.xmlsoap.org/wsdl/";
  xmlns:xalan="http://xml.apache.org/xslt";
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  xmlns:tns="urn:bpel:jiap"
  targetNamespace="urn:bpel:jiap"
  >
  <types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace=
"urn:bpel:jiap">
      <complexType xmlns="http://schemas.xmlsoap.org/wsdl/"; name=
"syncSubsidyAgreementRequestMsg">
        <sequence>
            <complexType name="subsidyAgreementRequest">
            <sequence>
                <element name="address" type="xsd:string"/>
            </sequence>
          </complexType>
        </sequence>
      </complexType>
    </schema>
  </types>
  <message name="syncSubsidyAgreementRequestMsgMessage">
    <part name="syncSubsidyAgreementRequestMsg" type=
"tns:syncSubsidyAgreementRequestMsg"/>
  </message>
</definitions>

<!-- EXPECTED complexType sans xmlns attribute -->
    <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace=
"urn:bpel:jiap">
      <complexType name="syncSubsidyAgreementRequestMsg">

Current Thread