2

We have two XML schemas with same element name but different namespaces. When I use xjc, the compiler is assigning elements to the same classpath and element. As shown below, the root issue is in the handling of the XML Schema namespace with leading digit; specifically 1.0 and 1.1. XJC is compiling these difference URIs to a the same classpath; specifically _1. This is causing collision with the same classpath:

com.companyabc.namespaces.eda.process._1.TheChangeType

What is the syntax in the bindings.xjb to bind 1.0 to _1_0 and 1.1 to _1_1 ?

Thanks!!!

XML Schema 1 : http://namespaces.companyABC.com/EDA/Process/1.0/TheChange

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:p10="http://namespaces.companyABC.com/EDA/Process/1.0"
targetNamespace="http://namespaces.companyABC.com/EDA/Process/1.0"
elementFormDefault="qualified">
<xs:element name="TheChange" type="p10:TheChangeType" />
<xs:complexType name="TheChangeType">
    <xs:sequence>
        <xs:element name="Field1" type="xs:string" />
    </xs:sequence>
</xs:complexType>
</xs:schema>

XML Schema 2 : http://namespaces.companyABC.com/EDA/Process/1.1/TheChange

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:p11="http://namespaces.companyABC.com/EDA/Process/1.1"
targetNamespace="http://namespaces.companyABC.com/EDA/Process/1.1"
elementFormDefault="qualified">
<xs:element name="TheChange" type="p11:TheChangeType" />
<xs:complexType name="TheChangeType">
    <xs:sequence>
        <xs:element name="Field1" type="xs:string" />
        <xs:element name="Field2" type="xs:string" />
    </xs:sequence>
</xs:complexType>
</xs:schema>

Error:

[ant:xjc] [ERROR] A class/interface with the same name "com.companyabc.namespaces.eda.process._1.TheChangeType" is already in use. Use a class customization to resolve this conflict.
[ant:xjc]   line 3 of file:/D:/source/1.0/TheChange.xsd

This is the solution using XSD schema annotation. Yet the solution should be implemented as a binding pattern in bindings.xjb versus annotations. Annotations will require each schema to be annotated, this is a problem.

<xsd:annotation>
    <xsd:appinfo>
        <jaxb:schemaBindings>
            <jaxb:package name="com.companyabc.namespaces.eda.process._1_0" />
        </jaxb:schemaBindings>
    </xsd:appinfo>
</xsd:annotation>

            <jaxb:package name="com.companyabc.namespaces.eda.process._1_1" />

How is this annotation implemented as a binding pattern in bindings.xjb?

Bevo
  • 530
  • 5
  • 17

0 Answers0