summaryrefslogtreecommitdiffstats
path: root/tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs')
-rw-r--r--tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs
new file mode 100644
index 0000000..afd6286
--- /dev/null
+++ b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/ValidateComponent.cs
@@ -0,0 +1,44 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+//
+using System;
+using System.Xml;
+using System.Xml.Schema;
+using System.Xml.XPath;
+
+namespace Microsoft.Ddue.Tools {
+
+ public class ValidateComponent : BuildComponent {
+
+ private XmlSchemaSet schemas = new XmlSchemaSet();
+
+ public ValidateComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {
+
+ XPathNodeIterator schema_nodes = configuration.Select("schema");
+ foreach (XPathNavigator schema_node in schema_nodes) {
+ string file = schema_node.GetAttribute("file", String.Empty);
+ schemas.Add(null, file);
+ }
+
+ }
+
+ public override void Apply (XmlDocument document, string key) {
+
+ // set the validate schema
+ document.Schemas = schemas;
+
+ // create a validation handler
+ ValidationEventHandler handler = new ValidationEventHandler(LogValidationError);
+
+ // validate the document
+ document.Validate(handler);
+
+ }
+
+ private void LogValidationError (Object o, ValidationEventArgs e) {
+ string message = String.Format("ValidationError: {0}", e.Message);
+ WriteMessage(MessageLevel.Warn, message);
+ }
+
+ }
+
+} \ No newline at end of file