peiyongz    2003/04/02 16:01:35

  Modified:    c/src/xercesc/dom/impl DOMProcessingInstructionImpl.hpp
                        DOMNodeImpl.cpp DOMEntityReferenceImpl.hpp
                        DOMEntityImpl.hpp DOMDocumentTypeImpl.hpp
                        DOMDocumentFragmentImpl.hpp DOMCDATASectionImpl.hpp
  Log:
  Using DOM*Impl*::fNode to invoke DOMNodeImpl::getTextContent(#1,#2)
  
  Revision  Changes    Path
  1.5       +5 -2      
xml-xerces/c/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp
  
  Index: DOMProcessingInstructionImpl.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMProcessingInstructionImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMProcessingInstructionImpl.hpp  16 Jan 2003 20:12:19 -0000      1.4
  +++ DOMProcessingInstructionImpl.hpp  3 Apr 2003 00:01:34 -0000       1.5
  @@ -83,8 +83,11 @@
   
   
   class CDOM_EXPORT DOMProcessingInstructionImpl: public DOMProcessingInstruction {
  -private:
  +public:
       DOMNodeImpl   fNode;
  +
  +private:
  +
       DOMChildNode  fChild;
       // use fCharacterData to store its data so that those character utitlites can 
be used
       DOMCharacterDataImpl   fCharacterData;
  
  
  
  1.23      +159 -57   xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp
  
  Index: DOMNodeImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMNodeImpl.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- DOMNodeImpl.cpp   2 Apr 2003 22:30:01 -0000       1.22
  +++ DOMNodeImpl.cpp   3 Apr 2003 00:01:34 -0000       1.23
  @@ -68,6 +68,13 @@
   #include "DOMAttrImpl.hpp"
   #include "DOMCasts.hpp"
   #include "DOMDocumentImpl.hpp"
  +#include "DOMCDATASectionImpl.hpp"
  +#include "DOMEntityReferenceImpl.hpp"
  +#include "DOMEntityImpl.hpp"
  +#include "DOMProcessingInstructionImpl.hpp"
  +#include "DOMCommentImpl.hpp"
  +#include "DOMDocumentFragmentImpl.hpp"
  +#include "DOMNotationImpl.hpp"
   
   #include <xercesc/dom/DOMImplementation.hpp>
   #include <xercesc/dom/DOMException.hpp>
  @@ -908,42 +915,135 @@
       return pattern;
   }
   
  -const XMLCh*     DOMNodeImpl::getTextContent(XMLCh* pzBuffer, unsigned int&
  -rnBufferLength) const
  +/***
  + *
  + *   Excerpt from 
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html#Node3-textContent
  + *
  + *   textContent of type DOMString, introduced in DOM Level 3 
  + *   
  + *   This attribute returns the text content of this node and its descendants. When 
it is defined 
  + *   to be null, setting it has no effect. 
  + *   
  + *   When set, any possible children this node may have are removed and replaced by 
a single Text node 
  + *   containing the string this attribute is set to. 
  + *
  + *   On getting, no serialization is performed, the returned string does not 
contain any markup. 
  + *   No whitespace normalization is performed, the returned string does not contain 
the element content 
  + *   whitespaces Fundamental Interfaces. 
  + *
  + *   Similarly, on setting, no parsing is performed either, the input string is 
taken as pure textual content.
  + *
  + *   The string returned is made of the text content of this node depending on its 
type, 
  + *   as defined below: 
  + *
  + *       Node type                                           Content          
  + *   ====================       
========================================================================
  + *     ELEMENT_NODE               concatenation of the textContent attribute value 
of every child node, 
  + *     ENTITY_NODE                         excluding COMMENT_NODE and 
PROCESSING_INSTRUCTION_NODE nodes. 
  + *     ENTITY_REFERENCE_NODE   This is the empty string if the node has no 
children. 
  + *     DOCUMENT_FRAGMENT_NODE 
  + *    
--------------------------------------------------------------------------------------------------
  + *     ATTRIBUTE_NODE
  + *     TEXT_NODE
  + *     CDATA_SECTION_NODE
  + *     COMMENT_NODE, 
  + *     PROCESSING_INSTRUCTION_NODE   nodeValue 
  + *    
--------------------------------------------------------------------------------------------------
  + *     DOCUMENT_NODE, 
  + *     DOCUMENT_TYPE_NODE, 
  + *     NOTATION_NODE                 null 
  + *
  + ***/
  +
  +const XMLCh*     DOMNodeImpl::getTextContent() const
   {
  -  unsigned int nRemainingBuffer = rnBufferLength;
  -  rnBufferLength = 0;
  -  if (pzBuffer)
  -    *pzBuffer = 0;
  -
  -  DOMNode *thisNode = castToNode(this);
  -  switch (thisNode->getNodeType()) {
  -    case DOMNode::ELEMENT_NODE:
  +
  +     unsigned int nBufferLength = 0;
  +
  +     getTextContent(NULL, nBufferLength);
  +     XMLCh* pzBuffer = 
(XMLCh*)((DOMDocumentImpl*)getOwnerDocument())->allocate(nBufferLength+1);
  +
  +     getTextContent(pzBuffer, nBufferLength);
  +     pzBuffer[nBufferLength] = 0;
  +
  +     return pzBuffer;
  +
  +}
  +
  +const XMLCh*    DOMNodeImpl::getTextContent(XMLCh* pzBuffer, unsigned int& 
rnBufferLength) const
  +{
  +
  +     unsigned int nRemainingBuffer = rnBufferLength;
  +     rnBufferLength = 0;
  +
  +     if (pzBuffer)   
  +             *pzBuffer = 0;
  +
  +     DOMNode *thisNode = castToNode(this);
  +
  +     switch (thisNode->getNodeType())
  +     {
  +     case DOMNode::ELEMENT_NODE:
       case DOMNode::ENTITY_NODE:
       case DOMNode::ENTITY_REFERENCE_NODE:
       case DOMNode::DOCUMENT_FRAGMENT_NODE:
       {
  -      DOMNode* current = thisNode->getFirstChild();
  -      while (current != NULL) {
  -        if (current->getNodeType() != DOMNode::COMMENT_NODE &&
  -            current->getNodeType() != DOMNode::PROCESSING_INSTRUCTION_NODE)
  -        {
  -          if (pzBuffer) {
  -            unsigned int nContentLength = nRemainingBuffer;
  -            ((DOMNodeImpl*)current)->getTextContent(pzBuffer +
  -rnBufferLength, nContentLength);
  -            rnBufferLength += nContentLength;
  -            nRemainingBuffer -= nContentLength;
  -          }
  -          else {
  -            unsigned int nContentLength = 0;
  -            ((DOMNodeImpl*)current)->getTextContent(NULL, nContentLength);
  -            rnBufferLength += nContentLength;
  -          }
  -        }
  -        current = current->getNextSibling();
  -      }
  +             DOMNode* current = thisNode->getFirstChild();
  +             DOMNodeImpl* nodeImpl;
  +
  +             while (current != NULL) 
  +             {
  +                     if (current->getNodeType() != DOMNode::COMMENT_NODE &&
  +                             current->getNodeType() != 
DOMNode::PROCESSING_INSTRUCTION_NODE)
  +                     {
  +                             switch (current->getNodeType())
  +                             {
  +                             case DOMNode::ELEMENT_NODE:
  +                                     nodeImpl = 
&(((DOMElementImpl*)current)->fNode);
  +                             case DOMNode::ATTRIBUTE_NODE:       
  +                                     nodeImpl = &(((DOMAttrImpl*)current)->fNode);
  +                             case DOMNode::TEXT_NODE:        
  +                                     nodeImpl = &(((DOMTextImpl*)current)->fNode);
  +                             case DOMNode::CDATA_SECTION_NODE:
  +                                     nodeImpl = 
&(((DOMCDATASectionImpl*)current)->fNode);
  +                             case DOMNode::ENTITY_REFERENCE_NODE:
  +                                     nodeImpl = 
&(((DOMEntityReferenceImpl*)current)->fNode);
  +                             case DOMNode::ENTITY_NODE:
  +                                     nodeImpl = &(((DOMEntityImpl*)current)->fNode);
  +                             case DOMNode::PROCESSING_INSTRUCTION_NODE:
  +                                     nodeImpl = 
&(((DOMProcessingInstructionImpl*)current)->fNode);
  +                             case DOMNode::COMMENT_NODE:
  +                                     nodeImpl = 
&(((DOMCommentImpl*)current)->fNode);
  +                             case DOMNode::DOCUMENT_NODE:        
  +                                     nodeImpl = 
&(((DOMDocumentImpl*)current)->fNode);
  +                             case DOMNode::DOCUMENT_TYPE_NODE:
  +                                     nodeImpl = 
&(((DOMDocumentTypeImpl*)current)->fNode);
  +                             case DOMNode::DOCUMENT_FRAGMENT_NODE:
  +                                     nodeImpl = 
&(((DOMDocumentFragmentImpl*)current)->fNode);
  +                             case DOMNode::NOTATION_NODE:
  +                                     nodeImpl = 
&(((DOMNotationImpl*)current)->fNode);
  +                             }
  +
  +                             if (pzBuffer)
  +                             {
  +                                     unsigned int nContentLength = nRemainingBuffer;
  +                                     nodeImpl->getTextContent(pzBuffer + 
rnBufferLength, nContentLength);
  +                                     rnBufferLength += nContentLength;
  +                                     nRemainingBuffer -= nContentLength;
  +                             }
  +                             else 
  +                             {
  +                                     unsigned int nContentLength = 0;
  +                                     nodeImpl->getTextContent(NULL, nContentLength);
  +                                     rnBufferLength += nContentLength;
  +                             }
  +                     }
  +
  +                     current = current->getNextSibling();
  +
  +             }
       }
  +
       break;
   
       case DOMNode::ATTRIBUTE_NODE:
  @@ -952,38 +1052,40 @@
       case DOMNode::COMMENT_NODE:
       case DOMNode::PROCESSING_INSTRUCTION_NODE:
       {
  -      const XMLCh* pzValue = thisNode->getNodeValue();
  -      unsigned int nStrLen = XMLString::stringLen(pzValue);
  -      if (pzBuffer) {
  -        unsigned int nContentLength = (nRemainingBuffer >= nStrLen) ?
  -nStrLen : nRemainingBuffer;
  -        XMLString::copyNString(pzBuffer + rnBufferLength, pzValue,
  -nContentLength);
  -        rnBufferLength += nContentLength;
  -        nRemainingBuffer -= nContentLength;
  -      }
  -      else {
  -        rnBufferLength += nStrLen;
  -      }
  +             const XMLCh* pzValue = thisNode->getNodeValue();
  +             unsigned int nStrLen = XMLString::stringLen(pzValue);
  +
  +             if (pzBuffer) 
  +             {
  +                     unsigned int nContentLength = (nRemainingBuffer >= nStrLen) ? 
nStrLen : nRemainingBuffer;
  +                     XMLString::copyNString(pzBuffer + rnBufferLength, pzValue, 
nContentLength);
  +                     rnBufferLength += nContentLength;
  +                     nRemainingBuffer -= nContentLength;
  +             }
  +             else 
  +             {
  +                     rnBufferLength += nStrLen;
  +             }
  +
       }
  +
       break;
  -  }
  -  return pzBuffer;
  -}
   
  -const XMLCh*     DOMNodeImpl::getTextContent() const
  -{
  -  unsigned int nBufferLength = 0;
  -  getTextContent(NULL, nBufferLength);
  -  XMLCh* pzBuffer = (XMLCh*)
  -((DOMDocumentImpl*)getOwnerDocument())->allocate(nBufferLength+1);
  -  getTextContent(pzBuffer, nBufferLength);
  -  pzBuffer[nBufferLength] = 0;
  -  return pzBuffer;
  -}
  +     /***
  +         DOCUMENT_NODE
  +              DOCUMENT_TYPE_NODE
  +              NOTATION_NODE
  +     ***/
  +     default:
   
  +             break;
  +     }
  +
  +     return pzBuffer;
  +
  +}
   
  -void             DOMNodeImpl::setTextContent(const XMLCh* textContent){
  +void DOMNodeImpl::setTextContent(const XMLCh* textContent){
       throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0);
   }
   
  
  
  
  1.4       +5 -2      xml-xerces/c/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp
  
  Index: DOMEntityReferenceImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMEntityReferenceImpl.hpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMEntityReferenceImpl.hpp        4 Nov 2002 15:07:34 -0000       1.3
  +++ DOMEntityReferenceImpl.hpp        3 Apr 2003 00:01:34 -0000       1.4
  @@ -82,8 +82,11 @@
   
   class CDOM_EXPORT DOMEntityReferenceImpl: public DOMEntityReference
   {
  -private:
  +public:
       DOMNodeImpl      fNode;
  +
  +private:
  +
       DOMParentNode    fParent;
       DOMChildNode     fChild;
   
  
  
  
  1.6       +4 -2      xml-xerces/c/src/xercesc/dom/impl/DOMEntityImpl.hpp
  
  Index: DOMEntityImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMEntityImpl.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DOMEntityImpl.hpp 4 Nov 2002 15:07:34 -0000       1.5
  +++ DOMEntityImpl.hpp 3 Apr 2003 00:01:34 -0000       1.6
  @@ -81,8 +81,10 @@
   class    DOMEntityReference;
   
   class CDOM_EXPORT DOMEntityImpl: public DOMEntity {
  -private:
  +public:
       DOMNodeImpl      fNode;
  +private:
  +
       DOMParentNode    fParent;
   
       const XMLCh *   fName;
  
  
  
  1.10      +5 -2      xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp
  
  Index: DOMDocumentTypeImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentTypeImpl.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DOMDocumentTypeImpl.hpp   4 Nov 2002 15:07:34 -0000       1.9
  +++ DOMDocumentTypeImpl.hpp   3 Apr 2003 00:01:34 -0000       1.10
  @@ -84,8 +84,11 @@
   class NamedNodeMapImpl;
   
   class CDOM_EXPORT DOMDocumentTypeImpl: public DOMDocumentType {
  -private:
  +public:
       DOMNodeImpl          fNode;
  +
  +private:
  +
       DOMParentNode        fParent;
       DOMChildNode         fChild;
   
  
  
  
  1.3       +4 -2      xml-xerces/c/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp
  
  Index: DOMDocumentFragmentImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMDocumentFragmentImpl.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DOMDocumentFragmentImpl.hpp       4 Nov 2002 15:07:34 -0000       1.2
  +++ DOMDocumentFragmentImpl.hpp       3 Apr 2003 00:01:35 -0000       1.3
  @@ -78,8 +78,10 @@
   
   
   class CDOM_EXPORT DOMDocumentFragmentImpl: public DOMDocumentFragment {
  -private:
  +public:
       DOMNodeImpl     fNode;
  +private:
  +
       DOMParentNode   fParent;
   
   
  
  
  
  1.5       +4 -2      xml-xerces/c/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp
  
  Index: DOMCDATASectionImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMCDATASectionImpl.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMCDATASectionImpl.hpp   4 Nov 2002 15:07:34 -0000       1.4
  +++ DOMCDATASectionImpl.hpp   3 Apr 2003 00:01:35 -0000       1.5
  @@ -81,8 +81,10 @@
   
   
   class CDOM_EXPORT DOMCDATASectionImpl: public DOMCDATASection {
  -private:
  +public:
       DOMNodeImpl           fNode;
  +private:
  +
       DOMParentNode         fParent;
       DOMChildNode          fChild;
       DOMCharacterDataImpl  fCharacterData;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to