Java – ct-props-correct error when parsing schema

javaxmlxsd

I'm using the JAXB xjc tool to generate some Java interface files from xsds. I'm running into a problem where I'm getting a tonne of errors of the form:

org.xml.sax.SAXParseException: ct-props-correct.4: Error for type 'COCT_MT110200CA.PayeeRole'. Duplicate attribute uses with the same name and target namespace are specified. Name of duplicate attribute use is 'nullFlavor'.

The relevant parts of the schema are as follows:

 <xs:complexType name="COCT_MT110200CA.Holder">
  <xs:sequence>
     <xs:group ref="InfrastructureRootElements"/>
     <xs:element name="payeeRole" type="COCT_MT110200CA.PayeeRole" minOccurs="1" maxOccurs="1">
     </xs:element>
  </xs:sequence>
  <xs:attributeGroup ref="InfrastructureRootAttributes"/>
  <xs:attribute name="nullFlavor" type="NullFlavor" use="optional"/>
  <xs:attribute name="typeCode" type="ParticipationType" use="optional" fixed="HLD"/>
</xs:complexType>

Where COCT_MT110200CA.PayeeRole is defined as:

<xs:complexType name="COCT_MT110200CA.PayeeRole">
  <xs:sequence>
     <xs:group ref="InfrastructureRootElements"/>
     <xs:element name="id" type="II" minOccurs="0" maxOccurs="unbounded">
     </xs:element>
     <xs:choice>
        <xs:element name="payeePerson" type="COCT_MT110200CA.PayeePerson" nillable="true"
                    minOccurs="0"
                    maxOccurs="1">
        </xs:element>
        <xs:element name="payeeOrganization" type="COCT_MT110200CA.PayeeOrganization"
                    nillable="true"
                    minOccurs="0"
                    maxOccurs="1">
        </xs:element>
     </xs:choice>
  </xs:sequence>
  <xs:attributeGroup ref="InfrastructureRootAttributes"/>
  <xs:attribute name="nullFlavor" type="NullFlavor" use="optional"/>
  <xs:attribute name="classCode" type="RoleClass" use="optional" fixed="PAYEE"/>
</xs:complexType>

Any thoughts? I don't see anything wrong with this myself…

Best Answer

Oooh, I think I figured this out, there was a pesky attributeGroup (InfrastructureRootAttributes) there, and in that attributeGroup was the nullFlavor duplicate...