Reputation: 11
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
Please suggest.
Upvotes: -1
Views: 1487
Reputation: 106
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
Upvotes: 6
Reputation: 11
Issue Resolved by myself. did following steps.. may be useful for others
Renamed "name" element "ReturnData" in Cxml.dtd
Renamed "value" attr from TransportTerms,ShippingPaymentMethod,and TermsOfDeliveryCode in Cxml.dtd
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.
Upvotes: 1