jaxb-tools
jaxb-tools copied to clipboard
-XelementWrapper:delete should not delete a WrapperClass annotated with @XmlRootElement + Bug
I would expect classes annotated with @XmlRootElement
not to be deleted by the -XelementWrapper:delete
option, even if they only contain a collection. Is it a bug or an expected behavior ?
If you run my MRE at https://github.com/cheseaux/jaxb-maven-plugin-xew-bug/ you will also get a compilation error. The method createOrderItem
in ObjectFactory
refers to the non-existing class 'Order' (which was previously deleted by the ElementWrapper Plugin).
Other xew-related plugins have an option to define which classes to 'keep'.
For example, you would want to keep 'Order', but usually delete the wrapper-only object 'Orders'
@cheseaux : thanks for the MRE
-XelementWrapper
plugin is quite new so we need feedback from users if working or not. We'll try to fix it soon in next release 😄
The use case for annotate + xew makes more sense for inner collections.
The order object in this schema is eligble for xew deletion since it is defined only as a wrapper in the current xsd.
I think a more relevant example schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:complexType name="order">
<xsd:sequence>
<xsd:element name="items" type="items" minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
<xsd:attribute type="xsd:string" name="id" use="required"/>
</xsd:complexType>
<xsd:complexType name="items">
<xsd:sequence>
<xsd:element name="item" type="item" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="item">
<xsd:attribute type="xsd:string" name="foo" use="required"/>
</xsd:complexType>
</xsd:schema>
- Object 'order' is generated and annotated with an XMLRootElement
- Object 'items' is replaced with List<Item> and deleted from generation (xew) as it is a pure collection wrapper object
- Object 'item' is generated