From 6766bda7c9c6043fd115f18d597890b3f33b98da Mon Sep 17 00:00:00 2001
From: PeiYong Zhang <peiyongz@apache.org>
Date: Mon, 3 Jun 2002 23:12:07 +0000
Subject: [PATCH] DOMWriter feature constants changed

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173790 13f79535-47bb-0310-9956-ffa450edef68
---
 samples/DOMPrint/DOMPrint.cpp | 52 +++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 20 deletions(-)

diff --git a/samples/DOMPrint/DOMPrint.cpp b/samples/DOMPrint/DOMPrint.cpp
index d1d8ccbb4..afe562100 100644
--- a/samples/DOMPrint/DOMPrint.cpp
+++ b/samples/DOMPrint/DOMPrint.cpp
@@ -60,22 +60,22 @@
 
 // ---------------------------------------------------------------------------
 //  This sample program invokes the XercesDOMParser to build a DOM tree for
-//  the specified input file. It then invokes DOMWriter::writeNode() to
-//  serialize the resultant DOM tree into StdOutmyFormTarget, if no error
-//  occurs during the parsing.
+//  the specified input file. It then invokes DOMWriter::writeNode() to 
+//  serialize the resultant DOM tree into StdOutmyFormTarget, if no error 
+//  occurs during the parsing. 
 //
 //
 //  Note: Application needs to provide its own implementation of DOMErrorHandler
-//        (in this sample, the DOMPrintErrorHandler), if it would receive
+//        (in this sample, the DOMPrintErrorHandler), if it would receive 
 //        notification from the serializer in case any error occurs during
 //        the serialization.
 //
 //  Note: And application needs to provide its own implementation of DOMWriterFilter
 //        as well (in this sample, the DOMPrintFilter), if it would like to
-//        filtering out certain part of the DOM representation. but must be aware
+//        filtering out certain part of the DOM representation. but must be aware 
 //        that thus may render the resultant XML stream invalid.
 //
-//  Note: Application may choose any combination of characters as the end of line
+//  Note: Application may choose any combination of characters as the end of line 
 //        sequence to be used in the resultant XML stream, but must be aware that
 //        thus may render the serialized XML stream ill formed.
 //
@@ -85,7 +85,7 @@
 //        to terminate serialization prematurely, and thus no complete serialization
 //        be done.
 //
-//  Note: Application shall query the serializer first, before set any
+//  Note: Application shall query the serializer first, before set any 
 //        feature/mode(true, false), or be ready to catch exception if this
 //        feature/mode is not supported by the serializer.
 //
@@ -113,6 +113,7 @@
 
 #include <xercesc/framework/StdOutFormatTarget.hpp>
 #include <xercesc/parsers/XercesDOMParser.hpp>
+#include <xercesc/util/XMLUni.hpp>
 
 #include "DOMTreeErrorReporter.hpp"
 #include "DOMPrintFilter.hpp"
@@ -145,7 +146,7 @@
 //      then it is defaults to the encoding of the input XML file.
 //
 //  gMyEOLSequence
-//      The end of line sequence we are to output.
+//      The end of line sequence we are to output. 
 //
 //  gValScheme
 //      Indicates what validation scheme to use. It defaults to 'auto', but
@@ -412,8 +413,8 @@ int main(int argC, char* argV[])
         try
         {
 			// get a serializer, an instance of DOMWriter
-         XMLCh tempStr[100];
-         XMLString::transcode("Core", tempStr, 99);
+			XMLCh tempStr[100];
+			XMLString::transcode("Core", tempStr, 99);
 			DOMImplementation *impl          = DOMImplementationRegistry::getDOMImplementation(tempStr);
 			DOMWriter         *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
 
@@ -421,10 +422,21 @@ int main(int argC, char* argV[])
 			theSerializer->setNewLine(gMyEOLSequence);
 			theSerializer->setEncoding(gOutputEncoding);
 
-			// plug in user's own filter
+			// plug in user's own filter 
 			if (gUseFilter)
 			{
-				myFilter = new DOMPrintFilter;
+				// even we say to show attribute, but the DOMWriter
+				// will not show attribute nodes to the filter as
+				// the specs explicitly says that DOMWriter shall
+				// NOT show attributes to DOMWriterFilter.
+				//
+				// so DOMNodeFilter::SHOW_ATTRIBUTE has no effect.
+				// same DOMNodeFilter::SHOW_DOCUMENT_TYPE, no effect.
+				//
+				myFilter = new DOMPrintFilter(DOMNodeFilter::SHOW_ELEMENT   |
+                                              DOMNodeFilter::SHOW_ATTRIBUTE |
+                                              DOMNodeFilter::SHOW_DOCUMENT_TYPE 
+											  ); 
 				theSerializer->setFilter(myFilter);
 			}
 
@@ -433,11 +445,11 @@ int main(int argC, char* argV[])
 			theSerializer->setErrorHandler(myErrorHandler);
 
 			// set feature if the serializer supports the feature/mode
-			if (theSerializer->canSetFeature(DOMWriter::SplitCdataSections, gSplitCdataSections))
-				theSerializer->setFeature(DOMWriter::SplitCdataSections, gSplitCdataSections);
+			if (theSerializer->canSetFeature(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections))
+				theSerializer->setFeature(XMLUni::fgDOMWRTSplitCdataSections, gSplitCdataSections);
 			
-			if (theSerializer->canSetFeature(DOMWriter::DiscardDefaultContent, gDiscardDefaultContent))
-				theSerializer->setFeature(DOMWriter::DiscardDefaultContent, gDiscardDefaultContent);
+			if (theSerializer->canSetFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent))
+				theSerializer->setFeature(XMLUni::fgDOMWRTDiscardDefaultContent, gDiscardDefaultContent);
 
 			//
 			// Plug in a format target to receive the resultant
@@ -458,12 +470,12 @@ int main(int argC, char* argV[])
 
 			delete theSerializer;
 
-            //
-			// Filter, formatTarget and error handler
+            // 
+			// Filter, formatTarget and error handler 
 			// are NOT owned by the serializer.
 			//
-			delete myFormTarget;
-			delete myErrorHandler;
+			delete myFormTarget;      
+			delete myErrorHandler;   
 
 			if (gUseFilter)
 				delete myFilter;      	
-- 
GitLab