} else if (comp instanceof CollectionElement) {
CollectionElement coll = (CollectionElement)comp;
if (coll.children().size() > 0) {
// collection with children, choice or sequence from order
ComplexTypeElement type = new ComplexTypeElement();
if (coll.isOrdered()) {
// ordered children go to sequence element, repeating
SequenceElement seq = new SequenceElement();
type.setContentDefinition(seq);
} else {
// unordered children go to repeated choice element
ChoiceElement choice = new ChoiceElement();
type.setContentDefinition(choice);
}
type.setContentDefinition(buildCompositor(coll, 0, true, hold));
elem.setTypeDefinition(type);
} else {
// empty collection, item-type must reference a concrete mapping
String itype = coll.getItemTypeName();
TemplateElementBase ref = coll.getDefinitions().getSpecificTemplate(itype);
if (ref instanceof MappingElement) {
// item type with concrete mapping, make it an element
MappingDetail detail = m_detailDirectory.getMappingDetail((MappingElementBase)ref);
ComplexTypeElement type = new ComplexTypeElement();
SequenceElement seq = new SequenceElement();
type.setContentDefinition(seq);
ElementElement item = new ElementElement();
setElementRef(detail.getOtherName(), item, hold);
item.setMinOccurs(Count.COUNT_ZERO);
item.setMaxOccurs(Count.COUNT_UNBOUNDED);
seq.getParticleList().add(item);
elem.setTypeDefinition(type);
addItemDocumentation(coll, item);
} else {
// TODO: handle this with xs:any strict?
m_context.addWarning("Handling not implemented for unspecified mapping", coll);
}
}
} else {
// must be a structure, check children
StructureElement struct = (StructureElement)comp;
if (struct.children().size() > 0) {
// structure with children, choice or sequence from order
ComplexTypeElement type = new ComplexTypeElement();
if (struct.isOrdered()) {
// ordered children go to sequence element
SequenceElement seq = new SequenceElement();
type.setContentDefinition(seq);
} else {
// unordered children go to repeated choice element
ChoiceElement choice = new ChoiceElement();
type.setContentDefinition(choice);
}
type.setContentDefinition(buildCompositor(struct, 0, false, hold));
fillAttributes(struct, 0, type.getAttributeList(), hold);
elem.setTypeDefinition(type);
} else {
// no children, must be a mapping reference