1

I'm writing a custom plugin for XJC. I need XJC to generate extra classes which are not in the XSD Schema. How can I do that?

In run(Outline model, ...) we have access to model.getClasses() which are of a ClassOutline type. The problem is I need to add JDefinedClass, but I don't know where to add it. Each ClassOutline has only one implClass which I cannot replace or add.

aderesh
  • 927
  • 10
  • 22
  • 1
    Start here: http://stackoverflow.com/questions/9247730/what-is-the-role-of-classoutline-jclass-cclass-in-codemodel/9404341#9404341 – lexicore Jul 06 '16 at 07:18
  • Thank you for your reply @lexicore, it is very useful info. But is it possible to add classes which are not linked to schema? I don't know where I can add my own JDefinedClass for xjc to generate it. – aderesh Jul 12 '16 at 14:30

1 Answers1

1
private static void addAnotherClass(Outline model, String fullyQualifiedName) throws JClassAlreadyExistsException {
    model.getCodeModel()._class(fullyQualifiedName);
}

This will generate an empty class when called from the overridden run method of your XJC Plugin.

giro
  • 421
  • 1
  • 7
  • 19