/// <summary> /// After the body state - nothing except Comment PI S allowed. /// </summary> /// <param name="token">The consumed token.</param> void AfterBody(XmlToken token) { switch (token.Type) { case XmlTokenType.ProcessingInstruction: case XmlTokenType.Comment: { InMisc(token); break; } case XmlTokenType.EOF: { if (doc.Options.IsValidating && !XmlValidator.Run(doc)) { throw Errors.Xml(ErrorCode.XmlValidationFailed); } break; } default: { if (!token.IsIgnorable) { throw Errors.Xml(ErrorCode.XmlMissingRoot); } break; } } }
/// <summary> /// Runs the Validation with the given document. /// </summary> /// <param name="doc">The document to inspect.</param> /// <returns>True if the validation has been successful, otherwise false.</returns> public static Boolean Run(XMLDocument doc) { if (doc.Doctype == null || doc.Doctype.TypeDefinitions == null) return false; var validator = new XmlValidator(); validator.Definition = doc.Doctype.TypeDefinitions; if (!validator.Definition.IsInvalid && doc.DocumentElement.NodeName == doc.Doctype.Name) return validator.Inspect(doc.DocumentElement); return false; }
/// <summary> /// Runs the Validation with the given document. /// </summary> /// <param name="doc">The document to inspect.</param> /// <returns>True if the validation has been successful, otherwise false.</returns> public static Boolean Run(XMLDocument doc) { if (doc.Doctype == null || doc.Doctype.TypeDefinitions == null) { return(false); } var validator = new XmlValidator(); validator.Definition = doc.Doctype.TypeDefinitions; if (!validator.Definition.IsInvalid && doc.DocumentElement.NodeName == doc.Doctype.Name) { return(validator.Inspect(doc.DocumentElement)); } return(false); }