- if (newElement) {
- LocalComplexType complexType = new LocalComplexType();
- schemaElement.setComplexType(complexType);
- attributeIterator = parseElement.getAttributes();
- while (attributeIterator.hasNext()) {
- Attribute attribute = attributeIterator.next();
- addAttribute(attribute, complexType, currentNS);
- }
-
- } else {
- LocalComplexType complexType = schemaElement.getComplexType();
- attributeIterator = parseElement.getAttributes();
- Map<String,org.w3._2001.xmlschema.Attribute> currentAttributes = new HashMap<>();
- Iterator<Annotated> currentAttributeIterator = complexType.getAttributeOrAttributeGroup().iterator();
- while (currentAttributeIterator.hasNext()) {
- Annotated annotated = currentAttributeIterator.next();
- if (annotated instanceof org.w3._2001.xmlschema.Attribute) {
- org.w3._2001.xmlschema.Attribute schemaAttribute = (org.w3._2001.xmlschema.Attribute)annotated;
- String n = schemaAttribute.getName();
- if (n != null)
- currentAttributes.put(n, schemaAttribute);
- }
- }
- while (attributeIterator.hasNext()) {
- Attribute attribute = attributeIterator.next();
- org.w3._2001.xmlschema.Attribute schemaAttribute = currentAttributes.get(attribute.getName().getLocalPart());
- if (schemaAttribute == null) {
- addAttribute(attribute, complexType, currentNS);
- } else {
- QName newType = getType(attribute.getValue());
- updateAttributeType(schemaAttribute, newType);
- }
-
+ if (!elementStack.isEmpty()) {
+ ComplexType complexType = parentElement.getComplexType();
+ ExplicitGroup choice = complexType.getChoice();
+ if (choice == null) {
+ choice = new ExplicitGroup();
+ complexType.setChoice(choice);
+ choice.setMaxOccurs("unbounded");