Index: src/main/java/org/exolab/castor/builder/MemberFactory.java =================================================================== --- src/main/java/org/exolab/castor/builder/MemberFactory.java (Revision 6865) +++ src/main/java/org/exolab/castor/builder/MemberFactory.java (Arbeitskopie) @@ -67,6 +67,8 @@ import org.exolab.castor.xml.schema.Documentation; import org.exolab.castor.xml.schema.ElementDecl; import org.exolab.castor.xml.schema.Facet; +import org.exolab.castor.xml.schema.Group; +import org.exolab.castor.xml.schema.Order; import org.exolab.castor.xml.schema.Schema; import org.exolab.castor.xml.schema.SchemaNames; import org.exolab.castor.xml.schema.SimpleType; @@ -359,7 +361,7 @@ int maxOccurs = component.getUpperBound(); int minOccurs = component.getLowerBound(); if (simpleTypeCollection - || ((maxOccurs < 0 || maxOccurs > 1) && !(memberName.endsWith("Choice")))) { + || ((maxOccurs < 0 || maxOccurs > 1) && !this.isChoice(component))) { String vName = memberName + "List"; // if xmlName is null it means that @@ -454,6 +456,43 @@ } /** + * Determines if the given component represents a choice. + * + * @param component The XMLBindingComponent to check. + * @return true if and only if the given XMLBindingComponent represents a choice. Otherwise returns false + */ + private boolean isChoice(XMLBindingComponent component) { + Group group = this.getGroup(component.getAnnotated()); + if (group == null || group.getOrder() == null) { + return false; + } + + return group.getOrder().getType() == Order.CHOICE; + } + + /** + * Returns the given structure as Group if it represents one.
+ *
+ * If the given structure has the structure type GROUP this method returns the given + * structure itself (casted to Group). If the structure is of any other type or is null this method + * will return null + * + * @param structure The Structure to be returned as Group. + * @return The given structure if and only if it is a group. Otherwise returns null. + */ + private Group getGroup(Structure structure) { + if (structure == null) { + return null; + } + + if (structure.getStructureType() == Structure.GROUP) { + return (Group) structure; + } + + return null; + } + + /** * Handle default or fixed value, if any is set. * @param component The component on which a default value is set * @param classInfo The corresponding ClassInfo instance.