6

I am trying to generate java classes from sample xsd using jdk 1.6, xjc command. But I don't want to use annotations i.e I don't want to generated java classes to contain annotations. How can I do it?

sampath
  • 155
  • 1
  • 2
  • 7
  • hi sampath could get the code generated without annotations? i am also looking for an answer to exactly the same problem. – weima Sep 14 '15 at 16:14

2 Answers2

0

In JAXB (JSR-222) the only standard representation of the XML-binding metadata defined in the standard is JAXB annotations. Therefore an option to generate the classes without these annotations is of limited use.

I'm the EclipseLink JAXB (MOXy) lead an we do offer an XML (and JSON) representation of the JAXB metadata as an extension:

If you are interested in having the ability to generate this metadata instead of annotations please request an enhancement in our bug database against the MOXy component:

Albert Scholtz
  • 337
  • 3
  • 15
bdoughan
  • 147,609
  • 23
  • 300
  • 400
0

This question has two parts:

  • In the compile time you have to generate your code differently. You can write an XJC plugin to do this.
  • In the runtime you have to use the JAXB implementation which works without annotations (see Blaise's answer on this part).

See this question on XJC extensibility:

XJC - is it extensible?

You can write an XJC plugin which completely replaces the code generation. So I can imagine an XJC plugin which generates XML mappings for MOXy instead of annotations in classes. You can also do this with JAXB RI using an extra annotation reader, but it is much trickier as simply using MOXy.

Be warned, however, that writing advanced XJC plugins my be quite complex.

Community
  • 1
  • 1
lexicore
  • 42,748
  • 17
  • 132
  • 221