Skip to main content

@XmlRootElement with XJC

1 reply [Last post]
Joined: 2005-01-10
Points: 0

Is there a possibility to tell XJC's Ant task to generate @XmlRootElement annotations via option/binding?

I want to marshal an object to its xml representation but I am only getting its child nodes in the result stream.

Does the @XmlRootElement generation depend on the source schema structure?

Any help would be appreciated.
Best regards,


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-09
Points: 0

Yes, it depends on the source schema structure. For example, if you got an element declaration with anonymous complex type, XJC often generates a class with @XmlRootElement.

If you want to put an @XmlRootElement in an XJC-generated class, you can often achieve the same effect by writing:

class MyClass extends XJCGenerated {}