public override bool CheckValidity(XmlSchemaSet schemas, ValidationEventHandler validationEventHandler) {
XmlDocument ownerDocument;
if (source.NodeType == XmlNodeType.Document) {
ownerDocument = (XmlDocument)source;
}
else {
ownerDocument = source.OwnerDocument;
if (schemas != null) {
throw new ArgumentException(Res.GetString(Res.XPathDocument_SchemaSetNotAllowed, null));
}
}
if (schemas == null && ownerDocument != null) {
schemas = ownerDocument.Schemas;
}
if (schemas == null || schemas.Count == 0) {
throw new InvalidOperationException(Res.GetString(Res.XmlDocument_NoSchemaInfo));
}
DocumentSchemaValidator validator = new DocumentSchemaValidator(ownerDocument, schemas, validationEventHandler);
validator.PsviAugmentation = false;
return validator.Validate(source);
}