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

simplify: generating erroneous List properties instead of simple objects #85

Open
sfrenkiel opened this issue Aug 22, 2017 · 0 comments

Comments

@sfrenkiel
Copy link

Please check this small project: https://github.com/sfrenkiel/basicstest. It contains this xsd:

<xs:element name="wrapper">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="element" />
            <xs:choice>
                <xs:group ref="seq1"/>
                <xs:group ref="seq2"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>
<xs:group name="seq1">
    <xs:sequence>
        <xs:element name="oneA"/>
        <xs:element name="b"/>
    </xs:sequence>
</xs:group>
<xs:group name="seq2">
    <xs:sequence>
        <xs:element name="twoA"/>
        <xs:element name="b"/>
    </xs:sequence>
</xs:group>

If you run the pom and look at the generated class Wrapper.java, you'll see that all the properties are generated as lists of objects, not simple objects:

public class Wrapper {

protected List<Object> element;
protected List<Object> twoA;
protected List<Object> oneA;
protected List<Object> b;

...

There are 3 xsd files in the project. If you replace the contents of test.xsd with either works1.xsd or works2.xsd, and rerun maven, you'll see that Wrapper.java is generated as expected:

public class Wrapper {

@XmlElement(required = true)
protected Object element;
protected Object oneA;
protected Object b;

...

I suspect having element 'b' appear twice under the Wrapper hierarchy is causing the issue, although as 'b' only appears under separate elements within a 'choice' construct I don't believe this should be happening. Worse though is that this seems to cause the other properties to be generated as lists as well.

BTW, wrapping seq1 and seq2 in complexTypes also resolves the problem, however this approach isn't possible in the actual code I am working with.

Any insight is appreciated. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant