Title: Suppressing xmlns= attribute in element tags for marshaled output xml

Hi,

I am using one xsd that imports another xsd.   A.xsd imports B.xsd. I put in the castorbuilder.properties the namespace to package values so that A.xsd classes go in package a and B.xsd classes go in package b. I then use them to unmarshal xml and the output the marshaled xml. Everything works well. However, the output xml has the following:

Input xml =
<A></A>
output xml =
<?xml version="1.0" encoding="UTF-8"?>
<A xmlns="A.xsd"/>

Note the xmlns=”A.xsd” attribute.  It is because I used targetNamespace for each schema so that the A.xsd and B.xsd classes would be put in separate class packages. This example is simplified and the real xsds will be fairly complex.

 I want to keep the generated classes in separate packages, but I do not want the xmlns=”A.xsd” to appear on the marshaled xml element tags. Is there a way to suppress this attribute on elements on the marshaled xml?

Thanks in advance for any help.
John



File A.xsd:

<?xml version = "1.0" encoding = "UTF-8"?>
<!--Generated by Turbo XML 2.3.1.100. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
   targetNamespace = "A.xsd"
   xmlns:b = "B.xsd" >
  <xsd:import namespace = "B.xsd" schemaLocation = "B.xsd"/>
        <xsd:element name = "A">
                <xsd:complexType>
                        <xsd:all>
                                <xsd:element ref = "a1" minOccurs = "0"/>
                                <xsd:element ref = "a2" minOccurs = "0"/>
                                <xsd:element ref = "b:B" minOccurs = "0"/>
                        </xsd:all>
                </xsd:complexType>
        </xsd:element>
        <xsd:element name = "a1" type = "xsd:string"/>
        <xsd:element name = "a2" type = "xsd:string"/>
</xsd:schema>

File B.xsd:

<?xml version = "1.0" encoding = "UTF-8"?>
<!--Generated by Turbo XML 2.3.1.100. Conforms to w3c http://www.w3.org/2001/XMLSchema-->
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
   targetNamespace = "B.xsd">
        <xsd:element name = "B">
                <xsd:complexType>
                        <xsd:all>
                                <xsd:element ref = "b1" minOccurs = "0"/>
                                <xsd:element ref = "b2" minOccurs = "0"/>
                                <xsd:element ref = "BB" minOccurs = "0"/>
                        </xsd:all>
                </xsd:complexType>
        </xsd:element>
        <xsd:element name = "BB">
                <xsd:complexType>
                        <xsd:all>
                                <xsd:element ref = "bb1" minOccurs = "0"/>
                                <xsd:element ref = "bb2" minOccurs = "0"/>
                        </xsd:all>
                </xsd:complexType>
        </xsd:element>
        <xsd:element name = "b1" type = "xsd:string"/>
        <xsd:element name = "b2" type = "xsd:string"/>
        <xsd:element name = "bb1" type = "xsd:string"/>
        <xsd:element name = "bb2" type = "xsd:string"/>
</xsd:schema>


Reply via email to