From 7bb58212e30c976d36aa2de8b0df78ff22dc56ef Mon Sep 17 00:00:00 2001
From: "Unknown (aruna1)" <dev-null@apache.org>
Date: Tue, 12 Sep 2000 23:05:30 +0000
Subject: [PATCH] Changed get/set functions of expandEntityReferneces to
 createEntityReferenceNodes. expandEntityRefernce functions are there but
 deprecated.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@172393 13f79535-47bb-0310-9956-ffa450edef68
---
 src/parsers/DOMParser.cpp | 20 +++++++++---
 src/parsers/DOMParser.hpp | 64 +++++++++++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/src/parsers/DOMParser.cpp b/src/parsers/DOMParser.cpp
index 2c9582d5e..56071334c 100644
--- a/src/parsers/DOMParser.cpp
+++ b/src/parsers/DOMParser.cpp
@@ -97,7 +97,7 @@ DOMParser::DOMParser(XMLValidator* const valToAdopt) :
 
 fErrorHandler(0)
 , fEntityResolver(0)
-, fExpandEntityReferences(false)
+, fCreateEntityReferenceNodes(false)
 , fToCreateXMLDeclTypeNode(false)
 , fIncludeIgnorableWhitespace(true)
 , fNodeStack(0)
@@ -492,7 +492,7 @@ void DOMParser::docPI(  const   XMLCh* const    target
 
 void DOMParser::endEntityReference(const XMLEntityDecl& entDecl)
 {
-    if (fExpandEntityReferences == true)
+    if (fCreateEntityReferenceNodes == true)
     {
         fCurrentParent = fNodeStack->pop();
         fCurrentNode   = fCurrentParent;
@@ -665,7 +665,7 @@ void DOMParser::startElement(const  XMLElementDecl&         elemDecl
 
 void DOMParser::startEntityReference(const XMLEntityDecl& entDecl)
 {
-    if (fExpandEntityReferences == true)
+    if (fCreateEntityReferenceNodes == true)
     {
 		DOMString entName(entDecl.getName());
         DOM_EntityReference er = fDocument.createEntityReference(entName);
@@ -674,10 +674,20 @@ void DOMParser::startEntityReference(const XMLEntityDecl& entDecl)
         fCurrentParent = er;
         fCurrentNode = er;
 
-		//this entityRef needs to be stored in Entity map too.
+		// this entityRef needs to be stored in Entity map too.
+        // We'd decide later whether the entity nodes should be created by a 
+        // separated method in parser or not. For now just stick it in if 
+        // the ref nodes are created
 		EntityImpl* entity = (EntityImpl*)fDocumentType->entities->getNamedItem(entName);
 		entity->setEntityRef((EntityReferenceImpl*)er.fImpl);
-		fDocumentType->entities->setNamedItem(entity);
+        bool owned = entity->isOwned();
+        if (owned)
+            entity->isOwned(false);
+        
+        fDocumentType->entities->setNamedItem(entity);
+        
+        if (entity->isOwned != owned)
+            entity->isOwned(owned);
     }
 }
 
diff --git a/src/parsers/DOMParser.hpp b/src/parsers/DOMParser.hpp
index 3fc9a8fc0..32467e9ad 100644
--- a/src/parsers/DOMParser.hpp
+++ b/src/parsers/DOMParser.hpp
@@ -249,6 +249,7 @@ public :
     bool getExitOnFirstFatalError() const;
 
     /** Get the 'expand entity references' flag.
+      * DEPRECATED Use getCreateEntityReferenceNodes() instead.
       *
       * This method returns the state of the parser's expand entity
       * references flag.
@@ -260,7 +261,26 @@ public :
       */
     bool getExpandEntityReferences() const;
 
-    /** Get the 'include ignorable whitespace' flag.
+    /** Get the 'include entity references' flag
+      *
+      * This flag  specifies whether the parser is
+      * creating entity reference nodes in the DOM tree being produced.
+      * When the 'create' flag is
+      * true, the DOM tree will contain entity reference nodes. 
+      * When the 'create' flag is false, no entity reference nodes
+      * are included in the DOM tree.
+      * <p>The replacement text
+      * of the entity is included in either case, either as a
+      * child of the Entity Reference node or in place at the location
+      * of the reference.
+      *
+      * @return  The state of the create entity reference node
+      *               flag.
+      * @see #setCreateEntityReferenceNodes
+      */
+    bool  getCreateEntityReferenceNodes()const;
+
+   /** Get the 'include ignorable whitespace' flag.
       *
       * This method returns the state of the parser's include ignorable
       * whitespace flag.
@@ -366,6 +386,7 @@ public :
 
     /** Set the 'expand entity references' flag
       *
+      * DEPRECATED.  USE setCreateEntityReferenceNodes instead.
       * This method allows the user to specify whether the parser should
       * expand all entity reference nodes. When the 'do expansion' flag is
       * true, the DOM tree does not have any entity reference nodes. It is
@@ -379,7 +400,25 @@ public :
       */
     void setExpandEntityReferences(const bool expand);
 
-    /** Set the 'include ignorable whitespace' flag
+     /** Set the 'include entity references' flag
+      *
+      * This method allows the user to specify whether the parser should
+      * create entity reference nodes in the DOM tree being produced.
+      * When the 'create' flag is
+      * true, the DOM tree constains entity reference nodes. 
+      * When the 'create' flag is false, no entity reference nodes
+      * are included in the DOM tree.
+      * <p>The replacement text
+      * of the entity is included in either case, either as a
+      * child of the Entity Reference node or in place at the location
+      * of the reference.
+      *
+      * @param create The new state of the create entity reference nodes
+      *               flag.
+      */
+    void setCreateEntityReferenceNodes(const bool create);
+
+   /** Set the 'include ignorable whitespace' flag
       *
       * This method allows the user to specify whether a validating parser
       * should include ignorable whitespaces as text nodes.  It has no effect
@@ -1179,10 +1218,8 @@ private :
     //  fErrorHandler
     //      The installed SAX error handler, if any. Null if none.
     //
-    //  fExpandEntityReference
-    //      Indicates whether entity reference nodes should be expanded to
-    //      its constituent text nodes or just created a single (end result)
-    //      text node.
+    //  fCreateEntityReferenceNode
+    //      Indicates whether entity reference nodes should be created.
     //
     //  fIncludeIgnorableWhitespace
     //      Indicates whether ignorable whiltespace should be added to
@@ -1227,7 +1264,7 @@ private :
     DOM_Document            fDocument;
     EntityResolver*         fEntityResolver;
     ErrorHandler*           fErrorHandler;
-    bool                    fExpandEntityReferences;
+    bool                    fCreateEntityReferenceNodes;
     bool                    fIncludeIgnorableWhitespace;
     ValueStackOf<DOM_Node>* fNodeStack;
     bool                    fParseInProgress;
@@ -1306,7 +1343,11 @@ inline const EntityResolver* DOMParser::getEntityResolver() const
 
 inline bool DOMParser::getExpandEntityReferences() const
 {
-    return fExpandEntityReferences;
+    return fCreateEntityReferenceNodes;
+}
+inline bool DOMParser::getCreateEntityReferenceNodes() const
+{
+    return fCreateEntityReferenceNodes;
 }
 
 inline bool DOMParser::getIncludeIgnorableWhitespace() const
@@ -1330,7 +1371,12 @@ inline bool DOMParser::getToCreateXMLDeclTypeNode() const
 // ---------------------------------------------------------------------------
 inline void DOMParser::setExpandEntityReferences(const bool expand)
 {
-    fExpandEntityReferences = expand;
+    fCreateEntityReferenceNodes = expand;
+}
+
+inline void DOMParser::setCreateEntityReferenceNodes(const bool create)
+{
+    fCreateEntityReferenceNodes = create;
 }
 
 inline void DOMParser::setIncludeIgnorableWhitespace(const bool include)
-- 
GitLab