Esempio n. 1
0
        private bool ValidateXML(string configItem, string xmlToCheck)
        {
            XmlValidate xmlValidate = new XmlValidate();
            bool        validated   = false;
            string      xsdPath     = ConfigUtil.GetConfigItem(configItem);

            validated = xmlValidate.ValidateXml(xmlToCheck, xsdPath);

            return(validated);
        }
Esempio n. 2
0
        /// <summary>
        /// The main for the command line program
        /// </summary>
        /// <param name="args">the command line arguments</param>
        public static void Main(string[] args)
        {
            string xsdFilePath = "./gpx.xsd";
            string xsdExtFilePath = "./GpxExtPlj.xsd";

            bool useGpxExt = false;
            bool waitConsole = false;

            if (args.Length == 0)
            {
                Console.WriteLine("Bad argument.");
                Console.WriteLine("validateGpx.exe gpxfile [gpxext] [wait]");
                Console.WriteLine("Please provide an inputfile as the first argument and optionally true to halt the console");
                Console.WriteLine(string.Empty);
                Console.WriteLine("Example:");
                Console.WriteLine(@"validateGpx.exe 110715_075330.gpx.xml [true]");
                waitConsole = true;
            }
            else
            {
                // parse arguments:
                if (args.Length > 1)
                {
                    Console.Write("Options: ");
                }

                for (int argsIdx = 1; argsIdx < args.Length; argsIdx++)
                {
                    if (args[argsIdx] == "gpxext")
                    {
                        Console.Write("[gpxext]");
                        useGpxExt = true;
                    }
                    else if (args[argsIdx] == "wait")
                    {
                        Console.Write("[wait]");
                        waitConsole = true;
                    }
                }

                if (args.Length > 1)
                {
                    Console.WriteLine();
                }

                // check schema files available
                bool doIt = true;

                if (!File.Exists(xsdFilePath))
                {
                    Console.WriteLine("validateGpx.exe");
                    Console.WriteLine("gpx.xsd does not exist in executable directory.");
                    doIt = false;
                }

                if (useGpxExt)
                {
                    if (!File.Exists(xsdExtFilePath))
                    {
                        Console.WriteLine();
                        Console.WriteLine("validateGpx GpxExtPlj.xsd does not exist in executable directory.");
                        doIt = false;
                    }
                }
                else
                {
                    xsdExtFilePath = string.Empty;
                }

                if (doIt)
                {
                    XmlValidate xmlvalidate = new XmlValidate();
                    string xmlFilePath = args[0];
                    xmlvalidate.Validate(xmlFilePath, xsdFilePath, xsdExtFilePath);
                }
            }

            if (waitConsole)
            {
                Console.WriteLine("Hit a key to close");
                Console.ReadLine();
            }
        }