X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Ftools%2Fmono-xsd%2FNewMonoXSD.cs;h=06879b37c3d37bc0a65127325c5f1990d9f5bff4;hb=c642102c53f294c1032a06cf92e58efdd3176a34;hp=de7c0f992d3e81923383fda680faf5d9817e1b23;hpb=f30c880b86ce6abd9022f93d33cd4b9e552a2965;p=mono.git diff --git a/mcs/tools/mono-xsd/NewMonoXSD.cs b/mcs/tools/mono-xsd/NewMonoXSD.cs index de7c0f992d3..06879b37c3d 100644 --- a/mcs/tools/mono-xsd/NewMonoXSD.cs +++ b/mcs/tools/mono-xsd/NewMonoXSD.cs @@ -78,9 +78,12 @@ namespace Mono.Util { { new Driver().Run (args); } - catch (Exception ex) + catch (ApplicationException ex) { Console.WriteLine (ex.Message); + } + catch (Exception ex) + { Console.WriteLine (ex); } } @@ -118,7 +121,7 @@ namespace Mono.Util { { if ((arg.EndsWith (".dll") || arg.EndsWith (".exe")) && !arg.Substring (1).StartsWith ("generator:") && !arg.Substring (1).StartsWith ("g:")) { - if (!readingFiles) throw new Exception (incorrectOrder); + if (!readingFiles) throw new ApplicationException (incorrectOrder); assemblies.Add (arg); assemblyOptions = true; continue; @@ -207,6 +210,10 @@ namespace Mono.Util { Console.WriteLine (helpString); return; } + else if (option == "nologo") + { + // ignore, since we do not output a logo anyway + } else Error (unknownOption, option); } @@ -374,7 +381,7 @@ namespace Mono.Util { foreach (string fileName in schemaNames) { StreamReader sr = new StreamReader (fileName); - schemas.Add (XmlSchema.Read (sr, null)); + schemas.Add (XmlSchema.Read (sr, new ValidationEventHandler (HandleValidationError))); sr.Close (); if (targetFile == "") targetFile = Path.GetFileNameWithoutExtension (fileName); @@ -399,10 +406,10 @@ namespace Mono.Util { else { foreach (XmlSchema schema in schemas) { - if (!schema.IsCompiled) schema.Compile (null); - foreach (XmlSchemaObject ob in schema.Items) - if (ob is XmlSchemaElement) - qnames.Add (((XmlSchemaElement)ob).QualifiedName); + if (!schema.IsCompiled) schema.Compile (new ValidationEventHandler (HandleValidationError)); + foreach (XmlSchemaElement el in schema.Elements.Values) + if (!qnames.Contains (el.QualifiedName)) + qnames.Add (el.QualifiedName); } } @@ -472,14 +479,22 @@ namespace Mono.Util { Console.WriteLine ("Written file " + genFile); } + void HandleValidationError (object o, ValidationEventArgs e) + { + Console.WriteLine ("{0}: {1} {2}", + e.Severity == XmlSeverityType.Error ? "Error" : "Warning", + e.Message, + e.Exception != null ? e.Exception.Message : null); + } + public void Error (string msg) { - throw new Exception (msg); + throw new ApplicationException (msg); } public void Error (string msg, string param) { - throw new Exception (string.Format(msg,param)); + throw new ApplicationException (string.Format(msg,param)); } private string StripQuot (string input)