X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mcs%2Ftools%2Fmono-xmltool%2Fxmltool.cs;h=918e4a2d48d3cf4a113bfa63f40b3ee904f0dad7;hb=f60b8b5b22e614fac834acb48492923d7b0b8ffc;hp=bd2a4d67976b91b65190856fd87a1109409f7b3b;hpb=4a2ab5827d8811e257934d9b8735d147a144e9e0;p=mono.git diff --git a/mcs/tools/mono-xmltool/xmltool.cs b/mcs/tools/mono-xmltool/xmltool.cs index bd2a4d67976..918e4a2d48d 100644 --- a/mcs/tools/mono-xmltool/xmltool.cs +++ b/mcs/tools/mono-xmltool/xmltool.cs @@ -40,6 +40,7 @@ options: --validate-rnc relax-ng-compact-grammar-file [instances] --validate-nvdl nvdl-script-xml [instances] --validate-xsd xml-schema [instances] + --validate-xsd2 xml-schema [instances] (in .NET 2.0 validator) --validate-dtd instances --transform stylesheet instance-xml [output-xml] --prettyprint [source] [result] @@ -76,6 +77,9 @@ environment variable that affects behavior: ValidateNvdl (args); return; #endif + case "--validate-xsd2": + ValidateXsd2 (args); + return; case "--validate-xsd": ValidateXsd (args); return; @@ -138,6 +142,16 @@ environment variable that affects behavior: new RelaxngValidatingReader (xtr, p); if (Environment.GetEnvironmentVariable ("MONO_XMLTOOL_ERROR_DETAILS") == "yes") vr.ReportDetails = true; + else + vr.InvalidNodeFound += delegate (XmlReader source, string message) { + IXmlLineInfo li = source as IXmlLineInfo; + Console.WriteLine ("ERROR: {0} (at {1} line {2} column {3})", + message, + source.BaseURI, + li != null && li.HasLineInfo () ? li.LineNumber : 0, + li != null && li.HasLineInfo () ? li.LinePosition : 0); + return true; + }; while (!vr.EOF) vr.Read (); @@ -175,6 +189,19 @@ environment variable that affects behavior: } } + static void ValidateXsd2 (string [] args) + { + XmlReaderSettings s = new XmlReaderSettings (); + s.ValidationType = ValidationType.Schema; + s.Schemas.Add (null, args [1]); + for (int i = 2; i < args.Length; i++) { + XmlReader xr = XmlReader.Create (args [i], s); + while (!xr.EOF) + xr.Read (); + xr.Close (); + } + } + static void ValidateDtd (string [] args) { for (int i = 1; i < args.Length; i++) {