String uri = attributes.getURI(i);
String name = attributes.getLocalName(i);
QName attQName = new QName(uri, name);
XSDAttributeDeclaration decl = Schemas.getAttributeDeclaration(content, attQName);
if (decl == null) {
//check wether unknown attributes should be parsed
if (!parser.isStrict()) {
if (parser.getLogger().isLoggable(Level.FINE)) {
parser.getLogger().fine("Parsing unknown attribute: " + attQName);
}
//create a mock attribute and continue
decl = XSDFactory.eINSTANCE.createXSDAttributeDeclaration();
decl.setName(attQName.getLocalPart());
decl.setTargetNamespace(attQName.getNamespaceURI());
//set the type to be of string
XSDSimpleTypeDefinition type = (XSDSimpleTypeDefinition) XSDUtil.getSchemaForSchema(XSDUtil.SCHEMA_FOR_SCHEMA_URI_2001)
.getSimpleTypeIdMap()
.get("string");
decl.setTypeDefinition(type);
}
}
//TODO: validate, if there is no declaration for an attribute, then
//TODO: make sure no required attributes are missing
// validation should fail, this is being side stepped for now until
// a good way of handling the namespace attributes on the root
// element, for now we just ignore attributes we dont find in the
// schema
if (decl != null) {
AttributeInstance att = new AttributeImpl(decl);
att.setNamespace(decl.getTargetNamespace());
att.setName(decl.getName());
att.setText(attributes.getValue(i));
atts.add(att);
} else {
parser.getLogger().warning("Could not find attribute declaration: " + attQName);