diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-21 22:58:36 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2012-03-21 22:58:36 -0700 |
commit | 80028b1c5442c85909b889b3c52cfbd0c0121437 (patch) | |
tree | b1b651c08a349957bb3d26ad5234a266d8d3e42e /tools/Sandcastle/Source/BuildAssembler/BuildComponents/SaveComponent.cs | |
parent | f02ccf1e93367b7ab8bece3a2c53e960e98d221d (diff) | |
parent | e1455ee979b150d1ea4afdf1bc82a9e5cbc5b2ba (diff) | |
download | DotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.zip DotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.tar.gz DotNetOpenAuth-80028b1c5442c85909b889b3c52cfbd0c0121437.tar.bz2 |
Merge branch 'v4.0' into dev11
Conflicts:
src/DotNetOpenAuth.sln
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); } } } |