code: private void visit(final XmlSchema xmlSchema, XmlSchemaChoice xsdChoice,
              final int level, final ArrayNode avroFields)
              throws Xsd2AvroTranslatorException {
  
          log.debug("process started for choice");
  
          String firstAlternativeName = null;
          ArrayNode alternativeAvroFields = MAPPER.createArrayNode();
  
          for (XmlSchemaChoiceMember alternative : xsdChoice.getItems()) {
              if (alternative instanceof XmlSchemaElement) {
                  String alternativeName = getAvroFieldName((XmlSchemaElement) alternative);
                  if (firstAlternativeName == null) {
                      firstAlternativeName = alternativeName;
                  }
                  visit(xmlSchema, (XmlSchemaElement) alternative, level,
                          alternativeAvroFields);
              }
          }
          ObjectNode avroChoiceField = MAPPER.createObjectNode();
          avroChoiceField.put("name", firstAlternativeName + "Choice");
  
          ArrayNode alternativeAvroTypes = MAPPER.createArrayNode();
          for (int i = 0; i < alternativeAvroFields.size(); i++) {
              alternativeAvroTypes.add(alternativeAvroFields.get(i).get("type"));
          }
  
          avroChoiceField.put("type", alternativeAvroTypes);
  
          avroFields.add(avroChoiceField);
          log.debug("process ended for choice = " + firstAlternativeName
                  + "Choice");
      }
docs: Process a choice element.
  <p/>
  Visits all elements from the choice then creates an avro Choice using the
  types of each alternative.
  
  @param xmlSchema the input XML schema
  @param xsdChoice the choice element
  @param level the current level in the elements hierarchy.
  @param avroFields array of fields being populated
  @throws Xsd2AvroTranslatorException