private SchemaAttDef CheckIsXmlAttribute(XmlQualifiedName attQName)
{
SchemaAttDef attdef = null;
if (Ref.Equal(attQName.Namespace, _nsXml) && (_validationFlags & XmlSchemaValidationFlags.AllowXmlAttributes) != 0)
{ //Need to check if this attribute is an xml attribute
if (!_compiledSchemaInfo.Contains(_nsXml))
{ //We dont have a schema for xml namespace
// It can happen that the schemaSet already contains the schema for xml namespace
// and we just have a stale compiled schema info (for example if the same schema set is used
// by two validators at the same time and the one before us added the xml namespace schema
// via this code here)
// In that case it is actually OK to try to add the schema for xml namespace again
// since we're adding the exact same instance (the built in xml namespace schema is a singleton)
// The addition on the schemaset is an effective no-op plus it's thread safe, so it's better to leave
// that up to the schema set. The result of the below call will be simply that we update the
// reference to the comipledSchemaInfo - which is exactly what we want in that case.
// In theory it can actually happen that there is some other schema registered for the xml namespace
// (other than our built in one), and we don't know about it. In that case we don't support such scenario
// as the user is modifying the schemaset as we're using it, which we don't support
// for bunch of other reasons, so trying to add our built-in schema won't make it worse.
AddXmlNamespaceSchema();
}
_compiledSchemaInfo.AttributeDecls.TryGetValue(attQName, out attdef); //the xml attributes are all global attributes
}
return attdef;
}