}
// generate schema equivalents for content components of container
ArrayList comps = cont.getContentComponents();
for (int i = offset; i < comps.size(); i++) {
IComponent comp = (IComponent)comps.get(i);
if (comp.hasName()) {
// create element for named content component
ElementElement element = buildElement(comp, repeat, hold);
if (comp instanceof StructureElementBase) {
addItemDocumentation((StructureElementBase)comp, element);
}
cdef.getParticleList().add(element);
} else if (comp instanceof ContainerElementBase) {
ContainerElementBase contain = (ContainerElementBase)comp;
boolean iscoll = comp instanceof CollectionElement;
if (contain.children().size() > 0) {
// no element name, but children; handle with recursive call
CommonCompositorDefinition part = buildCompositor(contain, 0, iscoll, hold);
addCompositorPart(part, cdef);
} else if (iscoll) {
// collection without a wrapper element
CollectionElement coll = (CollectionElement)comp;
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);
ElementElement item = new ElementElement();
QName oname = detail.getOtherName();
setElementRef(oname, item, hold);
item.setMinOccurs(Count.COUNT_ZERO);
item.setMaxOccurs(Count.COUNT_UNBOUNDED);
addItemDocumentation(coll, item);
cdef.getParticleList().add(item);
} else {
// TODO: handle this with xs:any strict?
m_context.addWarning("Handling not implemented for unspecified mapping", coll);
}
} else if (comp instanceof StructureElement) {
// no children, must be mapping reference
StructureElement struct = (StructureElement)comp;
MappingElementBase ref = (MappingElementBase)struct.getEffectiveMapping();
if (ref == null) {
// TODO: handle this with xs:any strict?
m_context.addWarning("Handling not implemented for unspecified mapping", struct);
} else {
// handle mapping reference based on form and name use
MappingDetail detail = m_detailDirectory.getMappingDetail(ref);
if (ref.isAbstract()) {
// abstract inline treated as group
GroupRefElement group = new GroupRefElement();
setGroupRef(detail.getOtherName(), group, hold);
if (comp.isOptional()) {
group.setMinOccurs(Count.COUNT_ZERO);
}
cdef.getParticleList().add(group);
} else {
// concrete treated as element reference
ElementElement elem = new ElementElement();
setElementRef(detail.getOtherName(), elem, hold);
if (comp.isOptional()) {
elem.setMinOccurs(Count.COUNT_ZERO);
}
addItemDocumentation(struct, elem);
cdef.getParticleList().add(elem);