public int Execute(IEnumerable <string> args) { List <string> unhandledArguments = options.Parse(args); if (unhandledArguments.Count > 0) { throw new ArgumentException("There are some unsupported options."); } if (String.IsNullOrEmpty(businessActionsXmlFileName)) { throw new ArgumentException("Missing business actions XML file name."); } if (String.IsNullOrEmpty(testSuiteSchemaNamespace)) { throw new ArgumentException("Missing XML namespace for the new test suite schema."); } // set output file name testSuiteSchemaFileName = Path.Combine(outputDir, Path.GetFileName(Path.ChangeExtension(businessActionsXmlFileName, "xsd"))); // create instance of class XmlValidationHelper XmlValidationHelper helper = new XmlValidationHelper(); // validating XML with schema file // xml document must have at least one action element helper.ValidateXmlDocument( businessActionsXmlFileName, Path.Combine(ConsoleApp.AccipioDirectoryPath, AccipioActionsXsdFileName)); // parse XML file BusinessActionsRepository businessActionsRepository = ParseXmlToObject(businessActionsXmlFileName); // generating XSD schema file with business actions validation parameters XmlDocument xmlSchemaDocument = GenerateXsdSchema(businessActionsRepository); // write xsd schema to file AccipioHelper.EnsureDirectoryPathExists(testSuiteSchemaFileName, true); using (Stream xsdSchemaDocument = File.Open(testSuiteSchemaFileName, FileMode.Create)) { xmlSchemaDocument.Save(xsdSchemaDocument); } System.Console.WriteLine(string.Format( CultureInfo.InvariantCulture, "XSD schema file '{0}' was created", Path.GetFullPath(testSuiteSchemaFileName))); return(0); }
public int Execute(IEnumerable <string> args) { List <string> unhandledArguments = options.Parse(args); if (unhandledArguments.Count > 0) { throw new ArgumentException("There are some unsupported options."); } if (String.IsNullOrEmpty(testReportFile)) { throw new ArgumentException("Missing Gallio report file name"); } XsltSettings xsltSettings = new XsltSettings(true, true); XmlDocument xsltDoc = new XmlDocument(); xsltDoc.Load( Path.Combine( ConsoleApp.AccipioDirectoryPath, xsltTransformationFileName)); XmlUrlResolver resolver = new XmlUrlResolver(); XslCompiledTransform transform = new XslCompiledTransform(true); transform.Load(xsltDoc, xsltSettings, resolver); string outputFileName = ConstructOutputFileName(); using (Stream inputStream = File.Open(testReportFile, FileMode.Open, FileAccess.Read)) { XmlReader reader = XmlReader.Create(inputStream); XmlWriterSettings writerSettings = new XmlWriterSettings(); writerSettings.Indent = true; writerSettings.NewLineOnAttributes = false; writerSettings.ConformanceLevel = ConformanceLevel.Auto; AccipioHelper.EnsureDirectoryPathExists(outputFileName, true); using (XmlWriter writer = XmlWriter.Create(outputFileName, writerSettings)) transform.Transform(reader, writer); } return(0); }