tags:

views:

270

answers:

1

Hello,

I'm using JAXB and xjc to compile my XML Schema into Java classes. I do not want to manually edit this generated classes. I have xml schema like that:

<xs:element name="root">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="items">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="item" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

The xjc generates a class Items that only contains a list of Item objects. Is there any chance to omit the class Items and have a list of Item objects directly in the Rootclass?

I know that this can be done with @XMLElementWrapper annotation, but I don't know how to tell xjc to create such.

Thanks for any suggestions!

Best regards, Markus

+1  A: 

Take a look at Bjarne Hansen's plugin for xjc: http://www.conspicio.dk/blog/bjarne/jaxb-xmlelementwrapper-plugin

Thomas