// For any substitution group: Build an implicit choice group, which
// may be used to replace the substitution groups head, if required.
for (Iterator iter = substitutionGroups.values().iterator(); iter.hasNext(); ) {
SubstitutionGroup group = (SubstitutionGroup) iter.next();
XSElementImpl head = (XSElementImpl) group.getHead();
XsObject object = head.getXsObject();
XsESchema syntaxSchema = object.getXsESchema();
// Find a name for the group
String namespace = syntaxSchema.getTargetNamespace().toString();
String localName = head.getName().getLocalName() + "Group";
XsQName suggestion = new XsQName(namespace, localName);
if (pSchema.getGroup(suggestion) != null) {
for (int i = 0; ; i++) {
suggestion = new XsQName(namespace, localName + i);
if (pSchema.getGroup(suggestion) == null) {
break;
}
}
}
XsTNamedGroup namedGroup = object.getObjectFactory().newXsTNamedGroup(syntaxSchema);
namedGroup.setName(new XsNCName(suggestion.getLocalName()));
XsTSimpleExplicitGroup choice = namedGroup.createChoice();
XSElement[] members = group.getMembers();
for (int j = 0; j < members.length; j++) {
XSElement member = members[j];