private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil) { if (elementDecl == null) { elementDecl = schemaInfo.GetElementDecl(elementName); } if (elementDecl != null) { if (xsiType.IsEmpty) { if (elementDecl.IsAbstract) { SendValidationEvent(ResXml.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace)); elementDecl = null; } } else if (xsiNil != null && xsiNil.Equals("true")) { SendValidationEvent(ResXml.Sch_XsiNilAndType); } else { SchemaElementDecl elementDeclXsi; if (!schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out elementDeclXsi) && xsiType.Namespace == _nsXs) { XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, _nsXs)); if (simpleType != null) { elementDeclXsi = simpleType.ElementDecl; } } if (elementDeclXsi == null) { SendValidationEvent(ResXml.Sch_XsiTypeNotFound, xsiType.ToString()); elementDecl = null; } else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block)) { SendValidationEvent(ResXml.Sch_XsiTypeBlockedEx, new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(context.LocalName, context.Namespace) }); elementDecl = null; } else { elementDecl = elementDeclXsi; } } if (elementDecl != null && elementDecl.IsNillable) { if (xsiNil != null) { context.IsNill = XmlConvert.ToBoolean(xsiNil); if (context.IsNill && elementDecl.DefaultValueTyped != null) { SendValidationEvent(ResXml.Sch_XsiNilAndFixed); } } } else if (xsiNil != null) { SendValidationEvent(ResXml.Sch_InvalidXsiNill); } } return(elementDecl); }