From 7cdafb34fd90d27e874265c97f8a6f8c17269852 Mon Sep 17 00:00:00 2001
From: PeiYong Zhang <peiyongz@apache.org>
Date: Mon, 10 Jun 2002 15:59:45 +0000
Subject: [PATCH] format-pretty-print partially supported

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173812 13f79535-47bb-0310-9956-ffa450edef68
---
 doc/domprint.xml                      |  1 +
 samples/DOMPrint/DOMPrint.cpp         | 22 +++++++++++++++++++++-
 scripts/sanityTest_ExpectedResult.log |  1 +
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/domprint.xml b/doc/domprint.xml
index e7045dddb..a47e1ef99 100644
--- a/doc/domprint.xml
+++ b/doc/domprint.xml
@@ -37,6 +37,7 @@ Options:
     -wscs=xxx   Enable/Disable split-cdata-sections.      Default on.  
     -wddc=xxx   Enable/Disable discard-default-content.   Default on.  
     -wflt=xxx   Enable/Disable filtering.                 Default off. 
+    -wfpp=xxx   Enable/Disable format-pretty-print.       Default off.
     -?          Show this help
   * = Default if not provided explicitly.
 
diff --git a/samples/DOMPrint/DOMPrint.cpp b/samples/DOMPrint/DOMPrint.cpp
index 6c7a3fb3f..5430d89ab 100644
--- a/samples/DOMPrint/DOMPrint.cpp
+++ b/samples/DOMPrint/DOMPrint.cpp
@@ -176,6 +176,7 @@ static const XMLCh*             gMyEOLSequence         = 0;
 static bool                     gSplitCdataSections    = true;
 static bool                     gDiscardDefaultContent = true;
 static bool                     gUseFilter             = false;
+static bool                     gFormatPrettyPrint     = false;
 
 static XercesDOMParser::ValSchemes    gValScheme       = XercesDOMParser::Val_Auto;
 
@@ -203,6 +204,7 @@ void usage()
             "    -wscs=xxx   Enable/Disable split-cdata-sections.      Default on  \n"
             "    -wddc=xxx   Enable/Disable discard-default-content.   Default on  \n"
             "    -wflt=xxx   Enable/Disable filtering.                 Default off \n"
+            "    -wfpp=xxx   Enable/Disable format-pretty-print.       Default off \n"
             "    -?          Show this help.\n\n"
             "  * = Default if not provided explicitly.\n\n"
             "The parser has intrinsic support for the following encodings:\n"
@@ -350,6 +352,21 @@ int main(int argC, char* argV[])
                 XMLPlatformUtils::Terminate();
                 return 2;
             }
+        }
+         else if (!strncmp(argV[parmInd], "-wfpp=", 6))
+        {
+            const char* const parm = &argV[parmInd][6];
+
+            if (!strcmp(parm, "on"))
+				gFormatPrettyPrint = true;
+			else if (!strcmp(parm, "off"))
+				gFormatPrettyPrint = false;
+            else
+            {
+                cerr << "Unknown -wfpp= value: " << parm << endl;
+                XMLPlatformUtils::Terminate();
+                return 2;
+            }
         }
          else
         {
@@ -461,7 +478,10 @@ int main(int argC, char* argV[])
 			if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent))
 				theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent);
 
-			//
+			if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint))
+				theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint);
+
+            //
 			// Plug in a format target to receive the resultant
 			// XML stream from the serializer.
             //
diff --git a/scripts/sanityTest_ExpectedResult.log b/scripts/sanityTest_ExpectedResult.log
index 352f12b61..1b147955f 100644
--- a/scripts/sanityTest_ExpectedResult.log
+++ b/scripts/sanityTest_ExpectedResult.log
@@ -427,6 +427,7 @@ Options:
     -wscs=xxx   Enable/Disable split-cdata-sections.      Default on  
     -wddc=xxx   Enable/Disable discard-default-content.   Default on  
     -wflt=xxx   Enable/Disable filtering.                 Default off 
+    -wfpp=xxx   Enable/Disable format-pretty-print.       Default off 
     -?          Show this help.
 
   * = Default if not provided explicitly.
-- 
GitLab