Skip to main content

@XmlRootElement with XJC

1 reply [Last post]
viviansteller
Offline
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,

Vivian

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kohsuke
Offline
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:

@XmlRootElement(...)
class MyClass extends XJCGenerated {}