in xmlschema-core/src/main/java/org/apache/ws/commons/schema/XmlSchemaSerializer.java [599:652]
Element serializeChoice(Document doc, XmlSchemaChoice choiceObj, XmlSchema schema)
throws XmlSchemaSerializerException {
// todo: handle any non schema attri ?
Element choice = createNewElement(doc, "choice", schema.getSchemaNamespacePrefix(),
XmlSchema.SCHEMA_NS);
if (choiceObj.getId() != null && choiceObj.getId().length() > 0) {
choice.setAttributeNS(null, "id", choiceObj.getId());
}
serializeMaxMinOccurs(choiceObj, choice);
/*
* if(choiceObj.maxOccursString != null) choice.setAttributeNS(null, "maxOccurs", choiceObj.maxOccursString);
* else if(choiceObj.maxOccurs > 1) choice.setAttributeNS(null, "maxOccurs", choiceObj.maxOccurs +"");
*/
if (choiceObj.getAnnotation() != null) {
Element annotation = serializeAnnotation(doc, choiceObj.getAnnotation(), schema);
choice.appendChild(annotation);
}
List<XmlSchemaChoiceMember> itemColl = choiceObj.getItems();
if (itemColl != null) {
int itemLength = itemColl.size();
for (int i = 0; i < itemLength; i++) {
XmlSchemaChoiceMember obj = itemColl.get(i);
if (obj instanceof XmlSchemaElement) {
Element el = serializeElement(doc, (XmlSchemaElement)obj, schema);
choice.appendChild(el);
} else if (obj instanceof XmlSchemaGroupRef) {
Element group = serializeGroupRef(doc, (XmlSchemaGroupRef)obj, schema);
choice.appendChild(group);
} else if (obj instanceof XmlSchemaChoice) {
Element inlineChoice = serializeChoice(doc, (XmlSchemaChoice)obj, schema);
choice.appendChild(inlineChoice);
} else if (obj instanceof XmlSchemaSequence) {
Element inlineSequence = serializeSequence(doc, (XmlSchemaSequence)obj, schema);
choice.appendChild(inlineSequence);
} else if (obj instanceof XmlSchemaAny) {
Element any = serializeAny(doc, (XmlSchemaAny)obj, schema);
choice.appendChild(any);
}
}
}
// process extension
processExtensibilityComponents(choiceObj, choice);
return choice;
}