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

Duplicate 'create...' methods are generated in ObjectFactory #39

Closed
vadimevf opened this issue Feb 23, 2015 · 2 comments
Closed

Duplicate 'create...' methods are generated in ObjectFactory #39

vadimevf opened this issue Feb 23, 2015 · 2 comments
Milestone

Comments

@vadimevf
Copy link

Hi!

Processing of the following schema fragment produces duplicate createDemoXewBugActionItem() method in the ObjectFactory class:

<xs:element name="DemoXewBug">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="Action">
        <xs:complexType>
          <xs:choice>
            <xs:element name="UpdateSomeItems">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:all>
                        <xs:element name="Key" type="xs:string"/>
                        <xs:element name="Value" type="xs:string"/>
                      </xs:all>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="UpdateOtherItems">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Item" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:all>
                        <xs:element name="Key" type="xs:string"/>
                        <xs:element name="Value" type="xs:string"/>
                      </xs:all>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:choice>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

I think that happens because XmlElementWrapperPlugin.renameFactoryMethod does not check for existence of the new method prior to renaming.

@dmak
Copy link
Owner

dmak commented Mar 6, 2015

Thanks for reporting the issue. The problem is even not in ObjectFactory: formally UpdateSomeItems → Item and UpdateOtherItems → Item may be completely different elements. Is it the case in reality for you? If not (as workaround) you could optimize your schema by extracting <Item> as separate element and using a reference to it in xs:sequence.

The solution in this particular case would be that one of the classes will be renamed, namely there will be two classes in the model: DemoXewBug.Action.Item and DemoXewBug.Action.Item1 (for example). If you have any ideas how to resolve name collision more nicely, you're welcome to suggest.

@dmak
Copy link
Owner

dmak commented Mar 10, 2015

I have uploaded jaxb-xew-plugin-1.5-SNAPSHOT.jar that should help with this issue. In particular, it appends the parent class name if there is a class name collision (e.g. UpdateOtherItemsItem). I think one should able to influence the class name by applying the appropriate JAXB customization.

@dmak dmak closed this as completed in 785cb1b Mar 11, 2015
@dmak dmak added this to the 1.5 milestone Mar 11, 2015
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

2 participants