{
XSTerm term = particle.getTerm();
switch(term.getType())
{
case XSConstants.MODEL_GROUP:
XSModelGroup modelGroup = (XSModelGroup)term;
// todo: investigate this
if(modelGroup.getParticles().getLength() > 0)
{
ModelGroupBinding groupBinding;
switch(modelGroup.getCompositor())
{
case XSModelGroup.COMPOSITOR_ALL:
groupBinding = new AllBinding(ctx.schema);
break;
case XSModelGroup.COMPOSITOR_CHOICE:
groupBinding = new ChoiceBinding(ctx.schema);
break;
case XSModelGroup.COMPOSITOR_SEQUENCE:
groupBinding = new SequenceBinding(ctx.schema);
break;
default:
throw new JBossXBRuntimeException("Unexpected model group: " + modelGroup.getCompositor());
}
ParticleBinding particleBinding = new ParticleBinding(groupBinding);
particleBinding.setMaxOccursUnbounded(particle.getMaxOccursUnbounded());
particleBinding.setMinOccurs(particle.getMinOccurs());
particleBinding.setMaxOccurs(particle.getMaxOccurs());
if (ctx.trace)
{
log.trace("created model group " + groupBinding);
}
if (ctx.processAnnotations)
{
XSAnnotation annotation = modelGroup.getAnnotation();
if(annotation != null)
{
customizeTerm(annotation, groupBinding, ctx.trace);
}
}