Bloom.CollectionTab.LibraryModel.ExportInDesignXml C# (CSharp) Method

ExportInDesignXml() public method

public ExportInDesignXml ( string path ) : void
path string
return void
        public void ExportInDesignXml(string path)
        {
            var pathToXnDesignXslt = FileLocator.GetFileDistributedWithApplication("xslts", "BloomXhtmlToDataForMergingIntoInDesign.xsl");

            #if DEBUG
             _bookSelection.CurrentSelection.OurHtmlDom.RawDom.Save(path.Replace(".xml",".xhtml"));
            #endif

            var dom = _bookSelection.CurrentSelection.OurHtmlDom.ApplyXSLT(pathToXnDesignXslt);

            using (var writer = XmlWriter.Create(path, CanonicalXmlSettings.CreateXmlWriterSettings()))
            {
                dom.Save(writer);
            }
        }

Usage Example

        private void OnExportToXmlForInDesign(object sender, EventArgs e)
        {
            using (var d = new InDesignXmlInformationDialog())
            {
                d.ShowDialog();
            }
            using (var dlg = new SaveFileDialog())
            {
                dlg.FileName         = Path.GetFileNameWithoutExtension(SelectedBook.GetPathHtmlFile()) + ".xml";
                dlg.InitialDirectory = SelectedBook.FolderPath;
                if (DialogResult.OK == dlg.ShowDialog())
                {
                    try
                    {
                        _model.ExportInDesignXml(dlg.FileName);
#if !MONO
                        Process.Start("explorer.exe", "/select, \"" + dlg.FileName + "\"");
#endif
                        Analytics.Track("Exported XML For InDesign");
                    }
                    catch (Exception error)
                    {
                        Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Could not export the book to XML");
                        Analytics.ReportException(error);
                    }
                }
            }
        }