From 6e4fb2399321383afbb1a460efcbde58ce2d3c8d Mon Sep 17 00:00:00 2001
From: Gareth Reakes <gareth@apache.org>
Date: Wed, 14 May 2003 19:23:20 +0000
Subject: [PATCH] Partial update of methods to
 http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html (the methods
 regarding DOMConfiguration).

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174970 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/dom/DOMDocument.hpp          | 15 ++++++++++++++-
 src/xercesc/dom/impl/DOMDocumentImpl.cpp | 15 ++++++++++++++-
 src/xercesc/dom/impl/DOMDocumentImpl.hpp |  4 +++-
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/xercesc/dom/DOMDocument.hpp b/src/xercesc/dom/DOMDocument.hpp
index 6536a4560..cf196b6c8 100644
--- a/src/xercesc/dom/DOMDocument.hpp
+++ b/src/xercesc/dom/DOMDocument.hpp
@@ -818,7 +818,13 @@ public:
      * normalizes attribute values, etc.
      * <br>Mutation events, when supported, are generated to reflect the
      * changes occuring on the document.
-     * @since DOM Level 3
+     * Note that this is a partial implementation. Not all the required features are implemented.
+     * Currently <code>DOMAttr</code> and <code>DOMText</code> nodes are normalized. 
+     * Features to remove <code>DOMComment</code> and <code>DOMCDATASection</code> work.
+     * The feature to normalize namespaces is implemented. This feature is called 
+     * "namespaces" and is incorectly documented in the current WD.
+     * @since DOM Level 3 
+     *
      */
     virtual void                   normalizeDocument() = 0;
 
@@ -828,6 +834,13 @@ public:
      * 
      * @return The <code>DOMConfiguration</code> from this <code>DOMDocument</code>
      *
+     * Note that this is a partial implementation. Not all the required features are 
+     * implemented and this is only used by normalizeDocument.
+     * Currently <code>DOMAttr</code> and <code>DOMText</code> nodes are normalized. 
+     * Features to remove <code>DOMComment</code> and <code>DOMCDATASection</code> work.
+     * The feature to normalize namespaces is implemented. This feature is called 
+     * "namespaces" and is incorectly documented in the current WD.
+     *
      * <p><b>"Experimental - subject to change"</b></p>
      * @since DOM Level 3
      */
diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.cpp b/src/xercesc/dom/impl/DOMDocumentImpl.cpp
index 3d6adb5ef..c023cb442 100644
--- a/src/xercesc/dom/impl/DOMDocumentImpl.cpp
+++ b/src/xercesc/dom/impl/DOMDocumentImpl.cpp
@@ -83,6 +83,7 @@
 #include "DOMEntityImpl.hpp"
 #include "DOMEntityReferenceImpl.hpp"
 #include "DOMNamedNodeMapImpl.hpp"
+#include "DOMNormalizer.hpp"
 #include "DOMNotationImpl.hpp"
 #include "DOMProcessingInstructionImpl.hpp"
 #include "DOMTextImpl.hpp"
@@ -119,6 +120,7 @@ DOMDocumentImpl::DOMDocumentImpl()
       fDocType(0),
       fDocElement(0),
       fNamePool(0),
+      fNormalizer(0),
       fNodeIDMap(0),
       fRanges(0),
       fNodeIterators(0),
@@ -151,6 +153,7 @@ DOMDocumentImpl::DOMDocumentImpl(const XMLCh *fNamespaceURI,
       fDocType(0),
       fDocElement(0),
       fNamePool(0),
+      fNormalizer(0),
       fNodeIDMap(0),
       fRanges(0),
       fNodeIterators(0),
@@ -228,6 +231,8 @@ DOMDocumentImpl::~DOMDocumentImpl()
         delete fRecycleBufferPtr;
     }
 
+    delete fNormalizer;
+
     //  Delete the heap for this document.  This uncerimoniously yanks the storage
     //      out from under all of the nodes in the document.  Destructors are NOT called.
     this->deleteHeap();
@@ -989,7 +994,11 @@ DOMNode* DOMDocumentImpl::adoptNode(DOMNode* source) {
 }
 
 void DOMDocumentImpl::normalizeDocument() {
-    throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
+
+    if(!fNormalizer) 
+        fNormalizer = new DOMNormalizer();
+
+    fNormalizer->normalizeDocument(this);
 }
 
 DOMConfiguration* DOMDocumentImpl::getDOMConfiguration() const {
@@ -999,6 +1008,10 @@ DOMConfiguration* DOMDocumentImpl::getDOMConfiguration() const {
     return fDOMConfiguration;
 }
 
+void DOMDocumentImpl::setDOMConfiguration(DOMConfiguration *config) {
+    fDOMConfiguration = config;
+}
+
 DOMNode *DOMDocumentImpl::importNode(DOMNode *source, bool deep, bool cloningDoc)
 {
     DOMNode *newnode=0;
diff --git a/src/xercesc/dom/impl/DOMDocumentImpl.hpp b/src/xercesc/dom/impl/DOMDocumentImpl.hpp
index ecdcc11c8..130e347c4 100644
--- a/src/xercesc/dom/impl/DOMDocumentImpl.hpp
+++ b/src/xercesc/dom/impl/DOMDocumentImpl.hpp
@@ -102,6 +102,7 @@ class DOMNotationImpl;
 class DOMProcessingInstructionImpl;
 class DOMTextImpl;
 class DOMNodeIteratorImpl;
+class DOMNormalizer;
 class DOMTreeWalkerImpl;
 class DOMNodeFilter;
 class DOMNodeFilterImpl;
@@ -267,6 +268,7 @@ public:
     virtual DOMNode*             adoptNode(DOMNode* source);
     virtual void                 normalizeDocument();
     virtual DOMConfiguration*    getDOMConfiguration() const;
+    virtual void                 setDOMConfiguration(DOMConfiguration *config);
 
     // helper functions to prevent storing userdata pointers on every node.
     void*                        setUserData(DOMNodeImpl* n,
@@ -369,7 +371,7 @@ private:
     DOMDocumentType*      fDocType;
     DOMElement*           fDocElement;
     DOMStringPool*        fNamePool;
-
+    DOMNormalizer*        fNormalizer;
     Ranges*               fRanges;
     NodeIterators*        fNodeIterators;
 
-- 
GitLab