in src/main/java/org/apache/ws/commons/schema/SchemaBuilder.java [1425:1479]
private XmlSchemaRedefine handleRedefine(XmlSchema schema, Element redefineEl, Element schemaEl) {
XmlSchemaRedefine redefine = new XmlSchemaRedefine(schema);
redefine.schemaLocation = redefineEl.getAttribute("schemaLocation");
final TargetNamespaceValidator validator = newIncludeValidator(schema);
if (schema.getSourceURI() != null) {
redefine.schema =
resolveXmlSchema(schema.getLogicalTargetNamespace(), redefine.schemaLocation,
schema.getSourceURI(), validator);
} else {
redefine.schema =
resolveXmlSchema(schema.getLogicalTargetNamespace(), redefine.schemaLocation, validator);
}
/*
* FIXME - This seems not right. Since the redefine should take into account the attributes of the
* original element we cannot just build the type defined in the redefine section - what we need to do
* is to get the original type object and modify it. However one may argue (quite reasonably) that the
* purpose of this object model is to provide just the representation and not the validation (as it
* has been always the case)
*/
for (Element el = XDOMUtil.getFirstChildElementNS(redefineEl, XmlSchema.SCHEMA_NS);
el != null;
el = XDOMUtil.getNextSiblingElementNS(el, XmlSchema.SCHEMA_NS)) {
if (el.getLocalName().equals("simpleType")) {
XmlSchemaType type = handleSimpleType(schema, el, schemaEl, false);
redefine.getSchemaTypes().put(type.getQName(), type);
redefine.getItems().add(type);
} else if (el.getLocalName().equals("complexType")) {
XmlSchemaType type = handleComplexType(schema, el, schemaEl, true);
redefine.getSchemaTypes().put(type.getQName(), type);
redefine.getItems().add(type);
} else if (el.getLocalName().equals("group")) {
XmlSchemaGroup group = handleGroup(schema, el, schemaEl);
redefine.getGroups().put(group.getQName(), group);
redefine.getItems().add(group);
} else if (el.getLocalName().equals("attributeGroup")) {
XmlSchemaAttributeGroup group = handleAttributeGroup(schema, el, schemaEl);
redefine.getAttributeGroups().put(group.getQName(), group);
redefine.getItems().add(group);
} else if (el.getLocalName().equals("annotation")) {
XmlSchemaAnnotation annotation = handleAnnotation(el);
redefine.setAnnotation(annotation);
}
// }
}
return redefine;
}