code: public XmlSchemaComplexType createXmlSchemaComplexType(
              final XsdDataItem xsdDataItem) {
  
          // All complex types are root complex types
          XmlSchemaComplexType xmlSchemaComplexType = new XmlSchemaComplexType(
                  getXsd(), true);
  
          XmlSchemaChoice xmlSchemaChoice = null;
  
          XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
          for (XsdDataItem child : xsdDataItem.getChildren()) {
              XmlSchemaElement xmlSchemaElement = createXmlSchemaElement(child);
              if (xmlSchemaElement != null) {
                  if (child.isRedefined()) {
                      xmlSchemaChoice = new XmlSchemaChoice();
                      xmlSchemaSequence.getItems().add(xmlSchemaChoice);
                      xmlSchemaChoice.getItems().add(xmlSchemaElement);
                  } else if (child.getRedefines() != null) {
                      if (xmlSchemaChoice == null) {
                          _log.warn("Item " + child.getCobolName()
                                  + " REDEFINES " + child.getRedefines()
                                  + " but redefined item is not a sibling");
                          xmlSchemaSequence.getItems().add(xmlSchemaElement);
                      } else {
                          xmlSchemaChoice.getItems().add(xmlSchemaElement);
                      }
                  } else {
                      xmlSchemaSequence.getItems().add(xmlSchemaElement);
                  }
              }
          }
  
          xmlSchemaComplexType.setParticle(xmlSchemaSequence);
          xmlSchemaComplexType.setName(xsdDataItem.getXsdTypeName());
  
          return xmlSchemaComplexType;
      }
docs: Create an XML schema complex type. We want to use Named complex types so
  we add them to the XSD directly. We add complex types before their
  children because its nicer for the XSD layout to list roots before leafs.
  Redefined and redefining elements are grouped into an XML Schema choice.
  A choice is created when an element marked as isRedefined is encountered
  and it groups all subsequent elements marked as redefines until a non
  redefining element is found.
  
  @param xsdDataItem COBOL data item decorated with XSD attributes
  @return a new complex type