* @param schema the schema currently being generated
* @param compositor sequence/choice/all that the generated wrapper Element will be added to
* @return AddToSchemaResult containing current ComplexType and TypeDefParticle
*/
private AddToSchemaResult addXmlElementWrapperToSchema(Property property, Schema schema, TypeDefParticle compositor) {
XmlElementWrapper wrapper = property.getXmlElementWrapper();
Element wrapperElement = new Element();
String name = wrapper.getName();
// handle nillable
wrapperElement.setNillable(wrapper.isNillable());
// namespace in not the target or ##default, create a ref with min/max = 1
String wrapperNS = wrapper.getNamespace();
if (!wrapperNS.equals(XMLProcessor.DEFAULT) && !wrapperNS.equals(schema.getTargetNamespace())) {
wrapperElement.setMinOccurs(Occurs.ONE);
wrapperElement.setMaxOccurs(Occurs.ONE);
String prefix = getOrGeneratePrefixForNamespace(wrapperNS, schema);
wrapperElement.setRef(prefix + COLON + name);
compositor.addElement(wrapperElement);
// assume that the element exists and does not need to be created
return null;
}
wrapperElement.setName(name);
if (wrapper.isRequired()) {
wrapperElement.setMinOccurs(Occurs.ONE);
} else {
wrapperElement.setMinOccurs(Occurs.ZERO);
}
compositor.addElement(wrapperElement);