diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-11 21:16:19 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-11 21:16:19 -0700 |
commit | 6c29eba4701e48222941981d499eb08686788a22 (patch) | |
tree | 5e8d9e3b9cc175d3b4e7f214e31d6b0e235467cb /tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs | |
parent | 4cc2523e6f2c2f9975d3328ae983cc509c449315 (diff) | |
download | DotNetOpenAuth-6c29eba4701e48222941981d499eb08686788a22.zip DotNetOpenAuth-6c29eba4701e48222941981d499eb08686788a22.tar.gz DotNetOpenAuth-6c29eba4701e48222941981d499eb08686788a22.tar.bz2 |
Upgraded to Sandcastle June 2010 release (changeset 54478).
Diffstat (limited to 'tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs')
-rw-r--r-- | tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs index 8b8fea9..6c767ce 100644 --- a/tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs +++ b/tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs @@ -53,6 +53,12 @@ namespace Microsoft.Ddue.Tools { linkPath = save_node.GetAttribute("link", String.Empty); if (String.IsNullOrEmpty(linkPath)) linkPath = "../html"; + // add-xhtml-namespace adds a default namespace for xhtml. Required by Help3 documentation. + string addXhtmlDeclaration = save_node.GetAttribute("add-xhtml-namespace", String.Empty); + if (!String.IsNullOrEmpty(addXhtmlDeclaration)) + writeXhtmlNamespace = Convert.ToBoolean(addXhtmlDeclaration); + + // encoding settings.CloseOutput = true; @@ -63,6 +69,9 @@ namespace Microsoft.Ddue.Tools { private string linkPath = null; + private bool writeXhtmlNamespace = false; + + public override void Apply (XmlDocument document, string key) { // set the evaluation context @@ -95,6 +104,12 @@ namespace Microsoft.Ddue.Tools { string targetDirectory = Path.GetDirectoryName(path); if (!Directory.Exists(targetDirectory)) Directory.CreateDirectory(targetDirectory); + if (writeXhtmlNamespace) + { + document.DocumentElement.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml"); + document.LoadXml(document.OuterXml); + } + // save the document // select_expression determines which nodes get saved. If there is no select_expression // we simply save the root node as before. If there is a select_expression, we evaluate the @@ -130,16 +145,16 @@ namespace Microsoft.Ddue.Tools { settings.ConformanceLevel = ConformanceLevel.Auto; using (StreamWriter output = File.CreateText(path)) { using (XmlWriter writer = XmlWriter.Create(output, settings)) { - XPathExpression select_xpath = select_expression.Clone(); - select_xpath.SetContext(context); - XPathNodeIterator ni = document.CreateNavigator().Select(select_expression); - while (ni.MoveNext()) { - if (ni.Current.NodeType == XPathNodeType.ProcessingInstruction && ni.Current.Name.Equals("literal-text")) { - writer.Flush(); - output.Write(ni.Current.Value); - } - else - ni.Current.WriteSubtree(writer); + XPathExpression select_xpath = select_expression.Clone(); + select_xpath.SetContext(context); + XPathNodeIterator ni = document.CreateNavigator().Select(select_expression); + while (ni.MoveNext()) { + if (ni.Current.NodeType == XPathNodeType.ProcessingInstruction && ni.Current.Name.Equals("literal-text")) { + writer.Flush(); + output.Write(ni.Current.Value); + } + else + ni.Current.WriteSubtree(writer); } } } |