in xmlschema-walker/src/main/java/org/apache/ws/commons/schema/walker/XmlSchemaScope.java [643:688]
private HashMap<QName, XmlSchemaAttrInfo> mergeAttributes(HashMap<QName, XmlSchemaAttrInfo> parentAttrs,
HashMap<QName, XmlSchemaAttrInfo> childAttrs) {
if ((parentAttrs == null) || parentAttrs.isEmpty()) {
return childAttrs;
} else if ((childAttrs == null) || childAttrs.isEmpty()) {
return parentAttrs;
}
HashMap<QName, XmlSchemaAttrInfo> newAttrs = new HashMap<QName, XmlSchemaAttrInfo>(parentAttrs);
/*
* Child attributes inherit all parent attributes, but may change the
* type, usage, default value, or fixed value.
*/
for (Map.Entry<QName, XmlSchemaAttrInfo> parentAttrEntry : parentAttrs.entrySet()) {
XmlSchemaAttrInfo parentAttr = parentAttrEntry.getValue();
XmlSchemaAttrInfo childAttr = childAttrs.get(parentAttrEntry.getKey());
if (childAttr != null) {
XmlSchemaAttrInfo newAttr = getAttribute(parentAttr.getAttribute(), true);
if (childAttr.getAttribute().getSchemaType() != null) {
newAttr.getAttribute().setSchemaType(childAttr.getAttribute().getSchemaType());
}
if (childAttr.getAttribute().getUse() != XmlSchemaUse.NONE) {
newAttr.getAttribute().setUse(childAttr.getAttribute().getUse());
}
// Attribute values may be defaulted or fixed, but not both.
if (childAttr.getAttribute().getDefaultValue() != null) {
newAttr.getAttribute().setDefaultValue(childAttr.getAttribute().getDefaultValue());
newAttr.getAttribute().setFixedValue(null);
} else if (childAttr.getAttribute().getFixedValue() != null) {
newAttr.getAttribute().setFixedValue(childAttr.getAttribute().getFixedValue());
newAttr.getAttribute().setDefaultValue(null);
}
newAttrs.put(newAttr.getAttribute().getQName(), newAttr);
}
}
return newAttrs;
}