element.setMinOccurs(Occurs.ZERO);
}
compositor.addElement(element);
} else {
// otherwise, add a choice of referenced elements.
Choice choice = new Choice();
if (property.getGenericType() != null) {
choice.setMaxOccurs(Occurs.UNBOUNDED);
}
if (!property.isRequired()){
choice.setMinOccurs(Occurs.ZERO);
}
for (ElementDeclaration elementDecl : referencedElements) {
Element element = new Element();
String localName = elementDecl.getElementName().getLocalPart();
String prefix = getPrefixForNamespace(schema, elementDecl.getElementName().getNamespaceURI());
if (elementDecl.getScopeClass() == GLOBAL.class){
if (prefix == null || prefix.equals(EMPTY_STRING)) {
element.setRef(localName);
} else {
element.setRef(prefix + COLON + localName);
}
} else {
Schema referencedSchema = getSchemaForNamespace(elementDecl.getElementName().getNamespaceURI());
element.setType(getTypeName(property, elementDecl.getJavaType(), referencedSchema));
element.setName(localName);
}
choice.addElement(element);
}
// handle XmlAnyElement case
if (property.isAny()) {
addAnyToSchema(property, choice, false);
}