public static void Main(string[] args) { string sourceFileName = String.Empty; string targetFileName = String.Empty; string rootNodeName = String.Empty; bool showHelp = false; List<string> nodesToSkip = new List<string>(); List<string> attributesToAdd = new List<string>(); var optionSet = new OptionSet() { { "s|source=", "The {SOURCE} xsd file to use to generate the XPaths (required).", v => sourceFileName = v }, { "t|target=", "The {TARGET} csv file containing the extracted XPaths (required).", v => targetFileName = v }, { "r|root:", "The {ROOT ELEMENT} to start from (optional). If not specified this defaults to the first root element found.", v => rootNodeName = v }, { "i|ignore:", "The {ELEMENT} to ignore when generating the XPaths (optional).", nodesToSkip.Add }, { "a|add:", "An additional {ATTRIBUTE} to extract from the element when generating the csv list (optional).", attributesToAdd.Add }, { "h|?|help", "Show this message and exit.", v => showHelp = v != null }, }; try { List<string> extraParameters = optionSet.Parse(args); if (extraParameters.Count > 0) { Console.WriteLine("XsdHelper: The following extra parameters are being ignored:\n {0}", String.Join("\n", extraParameters.ToArray())); } } catch (OptionException e) { Console.Write("XsdHelper: "); Console.WriteLine(e.Message); Console.WriteLine("Try `XsdHelper --help' for more information."); return; } showHelp |= String.IsNullOrEmpty(sourceFileName) || String.IsNullOrEmpty(targetFileName); if (showHelp) { ShowHelp(optionSet); return; } ValidateSuppliedFileArguments(sourceFileName, targetFileName); using (StreamWriter csvXPathFileWriter = new StreamWriter(targetFileName, false)) { Console.WriteLine("Loading schemas..."); SchemaParser parser = new SchemaParser(sourceFileName, csvXPathFileWriter); Console.WriteLine(String.Format("{0} files loaded", parser.LoadedSchemas.Count)); foreach (KeyValuePair<string, XmlSchema> loadedSchema in parser.LoadedSchemas.OrderBy(s => s.Key)) { Console.WriteLine(String.Format("File: {0}, Namespace: {1}", loadedSchema.Key, loadedSchema.Value.TargetNamespace)); } parser.ExtractXPaths(nodesToSkip, attributesToAdd, rootNodeName); csvXPathFileWriter.Close(); } }