Program: 190710
Project: 190710
Buggy source:
/** 
 * Generate the proper schema fragment for the given element property into the specified schema compositor. The element property may or may not represent a collection and it may or may not be wrapped.
 * @param ep the element property
 * @param compositor the schema compositor (sequence or all)
 */
private void handleElementProp(ElementPropertyInfo<T,C> ep,ExplicitGroup compositor){
  QName ename=ep.getXmlName();
  Occurs occurs=null;
  if (ep.isValueList()) {
    TypeRef<T,C> t=ep.getTypes().get(0);
    LocalElement e=compositor.element();
    QName tn=t.getTagName();
    e.name(tn.getLocalPart());
    List lst=e.simpleType().list();
    writeTypeRef(lst,t,"String_Node_Str");
    elementFormDefault.writeForm(e,tn);
    return;
  }
  if (ep.isCollection()) {
    if (ename != null) {
      LocalElement e=compositor.element();
      if (ename.getNamespaceURI().length() > 0) {
        if (!ename.getNamespaceURI().equals(this.uri)) {
          e.ref(new QName(ename.getNamespaceURI(),ename.getLocalPart()));
          return;
        }
      }
      elementFormDefault.writeForm(e,ename);
      ComplexType p=e.name(ename.getLocalPart()).complexType();
      if (ep.isCollectionNillable()) {
        e.nillable(true);
      }
 else {
        e.minOccurs(0);
      }
      if (ep.getTypes().size() == 1) {
        compositor=p.sequence();
      }
 else {
        compositor=p.choice();
        occurs=compositor;
      }
    }
 else {
      if (ep.getTypes().size() > 1) {
        compositor=compositor.choice();
        occurs=compositor;
      }
    }
  }
 else {
    if (ep.getTypes().size() > 1) {
      compositor=compositor.choice();
      occurs=compositor;
    }
  }
  for (  TypeRef<T,C> t : ep.getTypes()) {
    LocalElement e=compositor.element();
    if (occurs == null)     occurs=e;
    QName tn=t.getTagName();
    if (canBeDirectElementRef(t,tn) || (!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length() > 0)) {
      e.ref(tn);
    }
 else {
      e.name(tn.getLocalPart());
      writeTypeRef(e,t,"String_Node_Str");
      elementFormDefault.writeForm(e,tn);
    }
    if (t.isNillable()) {
      e.nillable(true);
    }
    if (t.getDefaultValue() != null)     e._default(t.getDefaultValue());
  }
  if (ep.isCollection()) {
    occurs.maxOccurs("String_Node_Str");
    occurs.minOccurs(0);
  }
 else {
    if (!ep.isRequired()) {
      occurs.minOccurs(0);
    }
  }
}

Fixed version (ground truth):
/** 
 * Generate the proper schema fragment for the given element property into the specified schema compositor. The element property may or may not represent a collection and it may or may not be wrapped.
 * @param ep the element property
 * @param compositor the schema compositor (sequence or all)
 */
private void handleElementProp(ElementPropertyInfo<T,C> ep,ExplicitGroup compositor){
  QName ename=ep.getXmlName();
  Occurs occurs=null;
  if (ep.isValueList()) {
    TypeRef<T,C> t=ep.getTypes().get(0);
    LocalElement e=compositor.element();
    QName tn=t.getTagName();
    e.name(tn.getLocalPart());
    List lst=e.simpleType().list();
    writeTypeRef(lst,t,"String_Node_Str");
    elementFormDefault.writeForm(e,tn);
    return;
  }
  if (ep.isCollection()) {
    if (ename != null) {
      LocalElement e=compositor.element();
      if (ename.getNamespaceURI().length() > 0) {
        if (!ename.getNamespaceURI().equals(this.uri)) {
          e.ref(new QName(ename.getNamespaceURI(),ename.getLocalPart()));
          return;
        }
      }
      elementFormDefault.writeForm(e,ename);
      ComplexType p=e.name(ename.getLocalPart()).complexType();
      if (ep.isCollectionNillable()) {
        e.nillable(true);
      }
 else {
        e.minOccurs(0);
      }
      if (ep.getTypes().size() == 1) {
        compositor=p.sequence();
      }
 else {
        compositor=p.choice();
        occurs=compositor;
      }
    }
 else {
      if (ep.getTypes().size() > 1) {
        compositor=compositor.choice();
        occurs=compositor;
      }
    }
  }
 else {
    if (ep.getTypes().size() > 1) {
      compositor=compositor.choice();
      occurs=compositor;
    }
  }
  for (  TypeRef<T,C> t : ep.getTypes()) {
    LocalElement e=compositor.element();
    if (occurs == null)     occurs=e;
    QName tn=t.getTagName();
    if (canBeDirectElementRef(t,tn) || (!tn.getNamespaceURI().equals(uri) && tn.getNamespaceURI().length() > 0)) {
      e.ref(tn);
    }
 else {
      e.name(tn.getLocalPart());
      writeTypeRef(e,t,"String_Node_Str");
      elementFormDefault.writeForm(e,tn);
    }
    if (t.isNillable()) {
      e.nillable(true);
    }
    if (t.getDefaultValue() != null)     e._default(t.getDefaultValue());
  }
  if (ep.isCollection())   occurs.maxOccurs("String_Node_Str");
  if (!ep.isRequired())   occurs.minOccurs(0);
}