private XsltError Process() { if (this.validate) { // TODO: This will fail if it's not a file e.g. stdin XmlValidation validator = new XmlValidation(); using (StreamReader xml = new StreamReader(this.sourceFile)) { if (!validator.IsValid(xml)) { DisplayError(string.Empty, XsltError.ParseError, validator.LastException.Message); return(XsltError.ParseError); } } } List <string> undefinedPrefixes = this.xsltOptions.GetUndefinedPrefixes(); if (undefinedPrefixes.Count > 0) { DisplayCommandError(XsltError.MSXSL_E_PREFIX_UNDEFINED, undefinedPrefixes[0]); return(XsltError.MSXSL_E_PREFIX_UNDEFINED); } List <Tuple <string, string> > invalids = this.xsltOptions.GetInvalidArguments(); if (invalids.Count > 0) { DisplayError(invalids[0].Item2, XsltError.MSXSL_E_PARAM_CTXT, invalids[0].Item1); return(XsltError.MSXSL_E_PARAM_CTXT); } if (string.IsNullOrEmpty(this.stylesheetFile) && this.useProcessingInstruction) { string xml = File.ReadAllText(this.sourceFile); this.stylesheetFile = XslTransformation.GetPi(xml); this.useStylesheetStdIn = false; if (string.IsNullOrEmpty(this.stylesheetFile)) { DisplayError(string.Empty, XsltError.InvalidPi); return(XsltError.InvalidPi); } } if (!string.IsNullOrEmpty(this.xsltOptions.StartMode) && this.xsltOptions.StartMode.Contains(":")) { DisplayError(string.Format(CultureInfo.CurrentCulture, XsltResources.NameNotContainChar, ":"), XsltError.ModeContext, this.xsltOptions.StartMode); return(XsltError.ModeContext); } // TODO: Support Uris? // TODO: Support UNC? // For input & output XsltError fileError = XsltError.None; if (!this.useSourceStdIn) { fileError = this.TestFileExists(this.sourceFile); if (fileError != XsltError.None) { return(fileError); } } if (!this.useStylesheetStdIn) { fileError = this.TestFileExists(this.stylesheetFile); if (fileError != XsltError.None) { return(fileError); } } return(this.Transform()); }