-1

Issue: Unable to create java classes from cXML.dtd using java xjc

version I am using is 1.2.032

command used : xjc -dtd cXML.dtd

Error : parsing a schema... [ERROR] Property "Name" is already defined. Use <jaxb:property> to resolve th is conflict.

Issue 1 : Line number around 573 issue is with the "name" as its duplicate (element as well as attribute).

issue 2: ShippingPaymentMethod,TermsOfDeliveryCode,TransportTerms uses "value" which is causing duplicate definations.

Solution as I understand==

I need custom binding.xml .. I tried various ways but unable to create correct binding.xml to solve this issue. once I have correct xml I can use following command to create generated classes. xjc -b binding.xml -dtd cXML.dtd

What I help I need

  1. please provide correct binding.xml if possible
  2. Is there any alternate way to generate java mappings for this cXML
  3. Is there possibilities to have XSD and then have java mapping from XSD?

Please suggest.

2 Answers2

6

FYI: you can also solve this with an external jax-b binding file that looks like this:

<xml-java-binding-schema xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
  <element name="ReturnData" type="class">
    <attribute name="name" property="nameAttribute"/>
  </element>
  <element name="ShippingPaymentMethod" type="class">
    <attribute name="value" property="valueAttribute"/>
  </element>
  <element name="TermsOfDeliveryCode" type="class">
    <attribute name="value" property="valueAttribute"/>
  </element>
  <element name="TransportTerms" type="class">
    <attribute name="value" property="valueAttribute"/>
  </element>
</xml-java-binding-schema>

The CXML spec is VERY annoying to generate JAX-B classes for because of their continued use of DTD over XML schema. This is especially annoying if you want to use the other DTDs (Invoice, Catalog, Fulfill) as they each redefine all the common elements but use their own versions of the cxml.requests, cxml.messages, cxml.responses entities

Bobby Lawrence
  • 106
  • 1
  • 6
1

Issue Resolved by myself. did following steps.. may be useful for others

  1. Renamed "name" element "ReturnData" in Cxml.dtd

  2. Renamed "value" attr from TransportTerms,ShippingPaymentMethod,and TermsOfDeliveryCode in Cxml.dtd

  3. Created java classes using
    xjc -dtd cXML.dtd

4.in Generated java classes changed xml annotation back to original.

So method names will be different but it will read and write correct XML.

  • cXML v 1.2.050 In addition I had to rename "serialNumber" of ATTLIST InvoiceDetailItemReference – A Kunin May 26 '21 at 00:47
  • Note: I would recommend to rename attribute elements by adding "Attribute", so it looks like nameAttribute, valueAttribute, serialNumberAttribute. – A Kunin May 26 '21 at 01:17