case SchemaBase.ATTRIBUTE_TYPE:
{
if (isIgnored()) {
delete = true;
} else {
AttributeElement attr = ((AttributeElement)component);
if (m_overrideType != null) {
attr.setType(m_overrideType);
}
QName type = attr.getType();
if (type == null) {
AttributeElement ref = attr.getReference();
if (ref != null) {
delete = !checkReference(ref);
} else if (!attr.isInlineType()) {
attr.setType(SchemaTypes.ANY_SIMPLE_TYPE.getQName());
}
} else {
QName repl = replaceAndReference(type, vctx);
if (repl == null) {
// TODO optionally make sure the attribute is optional?
delete = true;
} else if (repl != type) {
attr.setType(repl);
}
}
}
break;
}
case SchemaBase.ATTRIBUTEGROUP_TYPE:
{
if (component instanceof AttributeGroupRefElement) {
delete = !checkReference(((AttributeGroupRefElement)component).getReference());
}
break;
}
case SchemaBase.ELEMENT_TYPE:
{
ElementElement elem = ((ElementElement)component);
if (isIgnored()) {
// reference or definition determines handling
QName ref = elem.getRef();
if (ref == null) {
// definition, just delete all content
for (int i = 0; i < elem.getChildCount(); i++) {
elem.detachChild(i);
}
elem.compactChildren();
} else {
// reference may be to other namespace, so convert to qualified name string
StringBuffer buff = new StringBuffer();
buff.append('{');
if (ref.getUri() != null) {
buff.append(ref.getUri());
}
buff.append('}');
buff.append(ref.getName());
elem.setName(buff.toString());
elem.setRef(null);
}
elem.setType(SchemaTypes.ANY_TYPE.getQName());