Schema otherSchema = context.getSchemaSystem().getSchemaForNamespace(qname.getNamespaceURI());
schema.putPrefixForNamespace(qname.getPrefix(), qname.getNamespaceURI());
if (otherSchema == null) {
otherSchema = context.getSchemaSystem().newSchema(qname.getNamespaceURI());
}
Particle ref = otherSchema.getParticle(qname.getLocalPart());
if (ref == null) {
ref = otherSchema.newAttribute(qname.getLocalPart());
}
if (completed) {
ref.setAttribute("use", "optional");
}
Particle newAttribute = Particle.Factory.newReferenceInstance(schema, ref);
attributes.put(qname, newAttribute);
newAttribute.validate(context);
}
} else {
throw new XmlException("Illegal attribute!");
}
seen.add(qname);