0

I want to generate java dto's based on a provided dtd (cXML.DTD - see http://cxml.org/). The generation is done as part of the ant process by using com.sun.tools.xjc.XJCTask.

If I do so I am getting following error:

  [xjc] Compiling file:/sources/resources/cXML.dtd
  [xjc] [ERROR] Property "Name" is already defined. Use <jaxb:property> to resolve this conflict.
  [xjc]   line 706 of file:/sources/resources/cXML.dtd

The above can be solved by introducing jaxb bindings. Following binding I am using:

<jaxb:bindings version='2.1'
               xmlns:jaxb='http://java.sun.com/xml/ns/jaxb'
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb        http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jaxb/bindingschema_2_0.xsd"
               xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
        <!-- rename the name attribute-->
    <jaxb:bindings schemaLocation="cXML.dtd" node="/xs:schema">
            <jaxb:bindings node="//xs:complexType[@name='ReturnData']">
                <jaxb:bindings node=".//xs:attribute[@name='name']">
                    <jaxb:property name="name1"/>
                </jaxb:bindings>
            </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

But this results in the following error:

  [xjc] Compiling file:/sources/resources/cXML.dtd
  [xjc] [ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
  [xjc]   line 6 of file:/sources/resources/bindings.xjb

I wondering whats wrong? Calling http://java.sun.com/xml/ns/jaxb redirects to a generic oracle page... Is there something wrong with the definition of the bindings or does it relate to the 'non existing' binding namespace. What would be the correct binding namespace to use?

Is there maybe totally different, newer way without using jaxb to generate java dto's based on a DTD?

  • Make sure that version is supported by your jaxb runtime. See also https://stackoverflow.com/q/4552640/2834978 – LMC Sep 06 '21 at 18:55
  • tried 1.0, 2.0, 2.1, 2.2. Does not change anything... – dweloper Sep 07 '21 at 07:09
  • 1
    solution of: https://stackoverflow.com/questions/40908317/cxml-to-java-bindings-issues works and solves the above problem – dweloper Sep 07 '21 at 08:56

0 Answers0