3

The scenario is I have a bunch of schemas in .xsd format, which I can generate using XJC. However, I do not like one of the class generated using this approach, as a result, I would like to manually curate a replacement for that specific class. That class is being referenced by other classes in the schema. Is there a way of doing that?

Albert Cheng
  • 640
  • 6
  • 17
  • 1
    possible duplicate of [jaxb xjc mapping to existing domain objects](http://stackoverflow.com/questions/10420137/jaxb-xjc-mapping-to-existing-domain-objects) – bdoughan May 29 '13 at 18:43

3 Answers3

2

You can use an external binding file to configure XJC to do what you want. In the example below the existing class com.example.Foo will be used for the complex type named Foo.

binding.xml

<jxb:bindings schemaLocation="yourSchema.xsd">
    <jxb:bindings node="//xs:complexType[@name='Foo']">
        <jxb:class ref="com.example.Foo"/>
    </jxb:bindings>
</jxb:bindings>

XJC Call

xjc -d outputDir -b binding.xml yourSchema.xsd
bdoughan
  • 142,244
  • 22
  • 280
  • 377
0

You can manually create the class you have to use jaxb annotaion from javax.xml.bind.annotation package in you class.

below is the link for details of the same. http://docs.oracle.com/javaee/5/api/javax/xml/bind/annotation/package-summary.html

but if you can be more specific to your question like what you didnt like in autogenerated classes like class name or package name or anything else that will be a great help to answer this question.

daksh
  • 199
  • 1
  • 5
-1

As long as you are annotating the fields/properties with the same values, it is ok to manually change your class and also change any references(including the ObjectFactory class).