* Initial checkin. docval is a validation tool for monodoc xml.
authorAdam Treat <adam@mono-cvs.ximian.com>
Fri, 29 Mar 2002 00:24:49 +0000 (00:24 -0000)
committerAdam Treat <adam@mono-cvs.ximian.com>
Fri, 29 Mar 2002 00:24:49 +0000 (00:24 -0000)
svn path=/trunk/mcs/; revision=3477

mcs/doctools/src/Console/docval.cs [new file with mode: 0644]

diff --git a/mcs/doctools/src/Console/docval.cs b/mcs/doctools/src/Console/docval.cs
new file mode 100644 (file)
index 0000000..9c3b691
--- /dev/null
@@ -0,0 +1,94 @@
+//     docval.cs
+//
+//     Adam Treat (manyoso@yahoo.com)
+//     (C) 2002 Adam Treat
+//
+//     This program is free software; you can redistribute it and/or modify
+//     it under the terms of the GNU General Public License as published by
+//     the Free Software Foundation; either version 2 of the License, or
+//     (at your option) any later version.
+
+using System;
+using System.Xml;
+
+namespace Mono.Util {
+
+       class DocVal {
+
+               string file;
+
+               void Usage()
+               {
+                       Console.Write ("docval [file]\n\n");
+               }
+
+               public static void Main(string[] args)
+               {
+                       DocVal val = new DocVal(args);
+               }
+
+               public DocVal(string [] args)
+               {
+                       bool pass = true;
+                       file = null;
+                       int argc = args.Length;
+
+                       for(int i = 0; i < argc; i++) {
+                               string arg = args[i];
+                               if(arg.EndsWith(".xml")) {
+                                       file = arg;
+                               }
+                       }
+
+                       if(file == null) {
+                               Usage();
+                               return;
+                       }
+
+                       try {
+                               XmlTextReader read = new XmlTextReader(file);
+                               XmlValidatingReader validate = new XmlValidatingReader(read);
+                               validate.ValidationType = ValidationType.Auto;
+                               while (validate.Read()) {
+                                       switch (validate.NodeType) {
+                                               case XmlNodeType.XmlDeclaration:
+                                                       Console.WriteLine("** XML declaration");
+                                                       break;
+                                               case XmlNodeType.DocumentType:
+                                                       Console.WriteLine("** DocumentType node");
+                                                       break;
+                                               case XmlNodeType.Document:
+                                                       Console.WriteLine("** Document node");
+                                                       break;
+                                               case XmlNodeType.Element:
+                                                       Console.WriteLine("** Element: {0}", validate.Name);
+                                               break;
+                                               case XmlNodeType.EndElement:
+                                                       Console.WriteLine("** End Element: {0}", validate.Name);
+                                                       break;
+                                               case XmlNodeType.Text:
+                                                       Console.WriteLine("** Text: {0}", validate.Value);
+                                                       break;
+                                               case XmlNodeType.Comment:
+                                                       Console.WriteLine("** Comment: {1}", validate.Name, validate.Value);
+                                                       break;
+                                               case XmlNodeType.Whitespace:
+                                                       break;
+                                               default:
+                                                       pass = false;
+                                                       Console.WriteLine("** ERROR: Unknown node type");
+                                                       break;
+                                       }
+                               }
+                       } catch (Exception e) {
+                               pass = false;
+                               Console.WriteLine(e);
+                       }
+                       if(pass) {
+                               Console.Write("\n   Validation: PASSED!\n\n");
+                       } else {
+                               Console.Write("\n   Validation: FAILED!\n\n");
+                       }
+               }
+       }
+}