/*Function to validate the input document*/
        public void ValidateOutputFile(String outFile)
        {
            isValid = true;
            XmlTextReader       xml = new XmlTextReader(outFile);
            XmlValidatingReader xsd = new XmlValidatingReader(xml);

            try {
                xsd.ValidationType          = ValidationType.DTD;
                xsd.ValidationEventHandler += new ValidationEventHandler(MyValidationEventHandler);

                while (xsd.Read())
                {
                    errorText = xsd.ReadString();
                    if (errorText.Length > 100)
                    {
                        errorText = errorText.Substring(0, 100);
                    }
                }
                xsd.Close();

                Stream   stream = null;
                Assembly asm    = Assembly.GetExecutingAssembly();
                foreach (string name in asm.GetManifestResourceNames())
                {
                    if (name.EndsWith("Shematron.xsl"))
                    {
                        stream = asm.GetManifestResourceStream(name);
                        break;
                    }
                }

                XmlReader     rdr = XmlReader.Create(stream);
                XPathDocument doc = new XPathDocument(outFile);

                XslCompiledTransform trans = new XslCompiledTransform(false);
                trans.Load(rdr);

                XmlTextWriter myWriter = new XmlTextWriter(Path.GetDirectoryName(outFile) + "\\report.txt", null);
                trans.Transform(doc, null, myWriter);

                myWriter.Close();
                rdr.Close();

                StreamReader reader = new StreamReader(Path.GetDirectoryName(outFile) + "\\report.txt");
                if (!reader.EndOfStream)
                {
                    error  += reader.ReadToEnd();
                    isValid = false;
                }
                reader.Close();

                if (File.Exists(Path.GetDirectoryName(outFile) + "\\report.txt"))
                {
                    File.Delete(Path.GetDirectoryName(outFile) + "\\report.txt");
                }

                // Check whether the document is valid or invalid.
                if (isValid == false)
                {
                    if (error_MasterSub != "")
                    {
                        error_Exception = "Translation failed." + "\n" + "Validation error found while translating the following documents" + "\n" + " \"" + error_MasterSub + "\n" + error;
                    }
                    else
                    {
                        error_Exception = "Translated document is invalid." + "\n\n" + error;
                    }
                }
                else
                {
                    if (error_MasterSub != "")
                    {
                        error_Exception = "Translation failed." + "\n\n" + "Validation error found while translating the following documents" + "\n" + " \"" + error_MasterSub + "\n" + error;
                    }
                }
            } catch (UnauthorizedAccessException a) {
                xsd.Close();
                //dont have access permission
                String error = a.Message;
                report.AddLog("", "Validation Error of translated DAISY File: \n" + error, Report.ERROR_LEVEL);
            } catch (Exception a) {
                xsd.Close();
                //and other things that could go wrong
                String error = a.Message;
                report.AddLog("", "Validation Error of translated DAISY File: \n" + error, Report.ERROR_LEVEL);
            }
        }