dbertoni    00/05/26 12:18:28

  Modified:    c/src/XercesParserLiaison XercesDocumentBridge.cpp
                        XercesDocumentBridge.hpp
  Log:
  Added option to build all bridge nodes in constructor.  Necessary for 
thread-save sharing of the document.
  
  Revision  Changes    Path
  1.6       +30 -1     
xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.cpp
  
  Index: XercesDocumentBridge.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XercesDocumentBridge.cpp  2000/05/05 15:08:07     1.5
  +++ XercesDocumentBridge.cpp  2000/05/26 19:18:25     1.6
  @@ -79,6 +79,7 @@
   
   
   
  +#include "NullTreeWalker.hpp"
   #include "XercesAttrBridge.hpp"
   #include "XercesCommentBridge.hpp"
   #include "XercesCDATASectionBridge.hpp"
  @@ -97,7 +98,9 @@
   
   
   
  -XercesDocumentBridge::XercesDocumentBridge(const DOM_Document&       
theXercesDocument) :
  +XercesDocumentBridge::XercesDocumentBridge(
  +                     const DOM_Document&             theXercesDocument,
  +                     bool                                    
buildBridgeNodes) :
        XalanDocument(),
        m_xercesDocument(theXercesDocument),
        m_navigator(this),
  @@ -128,6 +131,32 @@
                m_nodeMap.addAssociation(theDoctype, m_doctype, false);
   
                m_nodes.insert(m_doctype);
  +     }
  +
  +     if (buildBridgeNodes == true)
  +     {
  +             // OK, let's build the nodes.  This makes things
  +             // thread-safe, so the document can be shared...
  +
  +             // First, build any children of the document...
  +             const XalanNode*        theChild = getFirstChild();
  +
  +             while(theChild != 0)
  +             {
  +                     theChild = theChild->getNextSibling();
  +             }
  +
  +             // OK, now walk everything below the document
  +             // element...
  +             const XalanNode* const  theDocumentElement =
  +                     getDocumentElement();
  +
  +             if (theDocumentElement != 0)
  +             {
  +                     NullTreeWalker  theTreeWalker;
  +
  +                     theTreeWalker.traverse(theDocumentElement, this);
  +             }
        }
   }
   
  
  
  
  1.2       +17 -1     
xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.hpp
  
  Index: XercesDocumentBridge.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesDocumentBridge.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XercesDocumentBridge.hpp  2000/04/11 14:39:29     1.1
  +++ XercesDocumentBridge.hpp  2000/05/26 19:18:26     1.2
  @@ -104,7 +104,23 @@
   
        friend class XercesBridgeNavigator;
   
  -     XercesDocumentBridge(const DOM_Document&        theXercesDocument);
  +     /**
  +      *
  +      * Constructor for XercesDocumentBridge.
  +      *
  +      * If the document will be shared amongst multiple threads of execution,
  +      * the parameter buildBridgeNodes must be true.  Otherwise, the bridge
  +      * nodes will be built on demand, a process which is not synchronized.
  +      * This could cause serious problems if multiple threads tried to visit
  +      * an unbuilt node at the same time.
  +      *
  +      * @param theXercesDocument The Xerces document to bridge
  +      * @param buildBridgeNodes If true, all of the bridge nodes will be 
built during construction.
  +      *
  +      */
  +     XercesDocumentBridge(
  +                     const DOM_Document&             theXercesDocument,
  +                     bool                                    
buildBridgeNodes = true);
   
        virtual
        ~XercesDocumentBridge();
  
  
  

Reply via email to