xjc: unable to honor class customization

admin

Administrator
Staff member
I'm trying to generate code from a single ~7,000 line cXML schema file generated from a DTD. I've been able to resolve a handful of conflicts with xjc customizations, but this last one has me stumped.

I've tried class and factory method customizations with no success.

When I try to apply a factory method customization, I wind up with the message:

Code:
  [xjc] [ERROR] compiler was unable to honor this class customization. It is attached to a wrong place, or its inconsistent with other bindings.

Others have run across this issue and have been able to resolve it. (<a href="https://dwuysan.wordpress.com/2012/...cause-a-collision-in-the-objectfactory-class/" rel="noreferrer">This link</a> was helpful.)

I'm wondering if my problem has something to do with the abstract nature of the element.

This detour has been frustrating and any help would be very much appreciated.

Here is the fragment from the schema:

Code:
  &lt;xs:element name="cxml.payment" abstract="true"&gt;
    &lt;xs:complexType&gt; &lt;!-- Line 2477 --&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element minOccurs="0" ref="PostalAddress"/&gt;
      &lt;/xs:sequence&gt;
      &lt;xs:attributeGroup ref="PCard.attlist"/&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:complexType name="cxml.payment"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="cxml.payment"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:element name="Payment" type="cxml.payment" /&gt;

 &lt;xs:element name="PCard" substitutionGroup="cxml.payment"/&gt;

  &lt;xs:attributeGroup name="PCard.attlist"&gt;
    &lt;xs:attribute name="number" use="required" type="number"/&gt;
    &lt;xs:attribute name="expiration" use="required" type="date"/&gt;
    &lt;xs:attribute name="name" type="string"/&gt;
  &lt;/xs:attributeGroup&gt;

Here are the raw errors:

Code:
&gt; compile:
&gt;      [echo] Compiling the schema...
&gt;       [xjc] Compiling file:/..cXML.xsd
&gt;       [xjc] [ERROR] A class/interface with the same name "cXML.CxmlPayment" is already in use. Use a class customization to
&gt; resolve this conflict.
&gt;       [xjc]   line 2477 of file:..cXML.xsd
&gt;       [xjc]
&gt;       [xjc] [ERROR] (Relevant to above error) another "CxmlPayment" is generated from here.
&gt;       [xjc]   line 2477 of file:..cXML.xsd
&gt;       [xjc]
&gt;       [xjc] [ERROR] (Relevant to above error) This confusing error happened most likely because the schema uses a technique called
&gt; "chameleon schema", which causes a single definition to be loaded
&gt; multiple times into different namespaces. See
&gt; http://forums.java.net/jive/thread.jspa?threadID=18631 for more about
&gt; this.
&gt;       [xjc]   line 2477 of file:..cXML.xsd
&gt;       [xjc]
&gt;       [xjc] [ERROR] Two declarations cause a collision in the ObjectFactory class.
&gt;       [xjc]   line 2477 of file:..cXML.xsd
&gt;       [xjc]
&gt;       [xjc] [ERROR] (Related to above error) This is the other declaration.
&gt;       [xjc]   line 2477 of file:..cXML.xsd
&gt;       [xjc]
&gt;       [xjc] failure in the XJC task. Use the Ant -verbose switch for more details