public void RunXslTransformCommand()
        {
            if (string.IsNullOrEmpty(stylesheetFileName))
            {
                stylesheetFileName = XmlEditorService.BrowseForStylesheetFile();

                if (string.IsNullOrEmpty(stylesheetFileName))
                {
                    return;
                }
            }

            using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) {
                try {
                    string xsltContent;
                    try {
                        xsltContent = GetFileContent(stylesheetFileName);
                    } catch (System.IO.IOException) {
                        monitor.ReportError(
                            GettextCatalog.GetString("Error reading file '{0}'.", stylesheetFileName), null);
                        return;
                    }
                    System.Xml.Xsl.XslCompiledTransform xslt =
                        XmlEditorService.ValidateStylesheet(monitor, xsltContent, stylesheetFileName);
                    if (xslt == null)
                    {
                        return;
                    }

                    XmlDocument doc = XmlEditorService.ValidateXml(monitor, Editor.Text, FileName);
                    if (doc == null)
                    {
                        return;
                    }

                    string newFileName = XmlEditorService.GenerateFileName(FileName, "-transformed{0}.xml");

                    monitor.BeginTask(GettextCatalog.GetString("Executing transform..."), 1);
                    using (XmlTextWriter output = XmlEditorService.CreateXmlTextWriter(Editor)) {
                        xslt.Transform(doc, null, output);
                        IdeApp.Workbench.NewDocument(
                            newFileName, "application/xml", output.ToString());
                    }
                    monitor.ReportSuccess(GettextCatalog.GetString("Transform completed."));
                    monitor.EndTask();
                } catch (Exception ex) {
                    string msg = GettextCatalog.GetString("Could not run transform.");
                    monitor.ReportError(msg, ex);
                    monitor.EndTask();
                }
            }
        }
 public void ValidateCommand()
 {
     TaskService.Errors.Clear();
     using (ProgressMonitor monitor = XmlEditorService.GetMonitor()) {
         if (IsSchema)
         {
             XmlEditorService.ValidateSchema(monitor, Editor.Text, FileName);
         }
         else
         {
             XmlEditorService.ValidateXml(monitor, Editor.Text, FileName);
         }
     }
 }