Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-XelementWrapper:delete should not delete a WrapperClass annotated with @XmlRootElement + Bug #506

Open
cheseaux opened this issue Feb 15, 2024 · 3 comments
Assignees
Labels
bug xjc-plugins Issue concerns basics plugins

Comments

@cheseaux
Copy link

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).

@mattrpav
Copy link
Collaborator

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'

@laurentschoelens laurentschoelens self-assigned this Feb 15, 2024
@laurentschoelens laurentschoelens added bug xjc-plugins Issue concerns basics plugins labels Feb 15, 2024
@laurentschoelens
Copy link
Collaborator

@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 😄

@mattrpav
Copy link
Collaborator

mattrpav commented Feb 15, 2024

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>
  1. Object 'order' is generated and annotated with an XMLRootElement
  2. Object 'items' is replaced with List and deleted from generation (xew) as it is a pure collection wrapper object
  3. Object 'item' is generated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug xjc-plugins Issue concerns basics plugins
Projects
None yet
Development

No branches or pull requests

3 participants