From 9a1c0d21415c4486a990bfccd2dc048a9b69032f Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 8 Feb 2012 23:47:53 +0000 Subject: [PATCH] laz2_write: option to preserve whitespace git-svn-id: trunk@35252 - --- components/lazutils/laz2_xmlwrite.pas | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/components/lazutils/laz2_xmlwrite.pas b/components/lazutils/laz2_xmlwrite.pas index 3b49f61d6d..95410976f0 100644 --- a/components/lazutils/laz2_xmlwrite.pas +++ b/components/lazutils/laz2_xmlwrite.pas @@ -31,7 +31,8 @@ uses Classes, laz2_DOM, SysUtils, laz2_xmlutils; type TXMLWriterFlag = ( - xwfSpecialCharsInAttributeValue // write #13 as #13 instead of as &xD; + xwfSpecialCharsInAttributeValue, // write #13 as #13 instead of as &xD; + xwfPreserveWhiteSpace ); TXMLWriterFlags = set of TXMLWriterFlag; @@ -645,13 +646,15 @@ begin begin SavedInsideTextNode := FInsideTextNode; wrtChr('>'); - FInsideTextNode := FCanonical or (Child.NodeType in [TEXT_NODE, CDATA_SECTION_NODE]); + FInsideTextNode := FCanonical or (Child.NodeType in [TEXT_NODE, CDATA_SECTION_NODE]) + or (xwfPreserveWhiteSpace in WriteFlags); //writeln(Space(FIndentCount*2),'TXMLWriter.VisitElement START FirstChild=',Child.ClassName,':',Child.LocalName,' FInsideTextNode=',FInsideTextNode); IncIndent; repeat //writeln(Space(FIndentCount*2),'TXMLWriter.VisitElement CHILD=',Child.ClassName,':',Child.LocalName,' FInsideTextNode=',FInsideTextNode); WriteNode(Child); - FInsideTextNode := FCanonical or (Child.NodeType in [TEXT_NODE, CDATA_SECTION_NODE]); + FInsideTextNode := FCanonical or (Child.NodeType in [TEXT_NODE, CDATA_SECTION_NODE]) + or (xwfPreserveWhiteSpace in WriteFlags); Child := Child.NextSibling; until Child = nil; DecIndent;