Bloom_ChorusPlugin.BloomHtmlFileTypeHandler.CarefullyWriteOutResultingXml C# (CSharp) Method

CarefullyWriteOutResultingXml() private static method

private static CarefullyWriteOutResultingXml ( HtmlFileForMerging oursXml, NodeMergeResult result ) : void
oursXml HtmlFileForMerging
result NodeMergeResult
return void
        private static void CarefullyWriteOutResultingXml(HtmlFileForMerging oursXml, NodeMergeResult result)
        {
            //REVIEW: it's not clear whether we need all this fancy xml cannonicalization, when we're going to run
            //it through html tidy to make html anyhow. This is just from the code we copied from.
            //Note it also is doing something careful with unicode.

            using (var writer = XmlWriter.Create(oursXml.GetPathToXHtml(), CanonicalXmlSettings.CreateXmlWriterSettings()))
            {
                var nameSpaceManager = new XmlNamespaceManager(new NameTable());
                //nameSpaceManager.AddNamespace("palaso", "urn://palaso.org/ldmlExtensions/v1");

                var readerSettings = new XmlReaderSettings
                                        {
                                            NameTable = nameSpaceManager.NameTable,
                                            IgnoreWhitespace = true,
                                            ConformanceLevel = ConformanceLevel.Auto,
                                            ValidationType = ValidationType.None,
                                            XmlResolver = null,
                                            CloseInput = true,
                                            DtdProcessing = DtdProcessing.Prohibit,
                                        };
                using (
                    var nodeReader = XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(result.MergedNode.OuterXml)),
                                                      readerSettings))
                {
                    writer.WriteNode(nodeReader, false);
                }
            }
        }