boolean isChoice = (parentCompositor instanceof Choice);
ComplexType parentType = type;
if (!helper.isAnnotationPresent(next.getElement(), XmlTransient.class)) {
// deal with the XmlElementWrapper case
if (!isChoice && next.isSetXmlElementWrapper()) {
XmlElementWrapper wrapper = next.getXmlElementWrapper();
Element wrapperElement = new Element();
String name = wrapper.getName();
if (name.equals("##default")) {
name = next.getPropertyName();
}
// 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("##default") && !wrapperNS.equals(schema.getTargetNamespace())) {
wrapperElement.setMinOccurs(Occurs.ONE);
wrapperElement.setMaxOccurs(Occurs.ONE);
String prefix = getOrGeneratePrefixForNamespace(wrapperNS, schema);
wrapperElement.setRef(prefix + ":" + name);
compositor.addElement(wrapperElement);
// assume that the element exists and does not need to be created
continue;
} else {
wrapperElement.setName(name);
if (wrapper.isRequired()) {
wrapperElement.setMinOccurs(Occurs.ONE);
} else {
wrapperElement.setMinOccurs(Occurs.ZERO);
}
compositor.addElement(wrapperElement);