dbertoni    01/01/28 18:30:31

  Modified:    c/src/XSLT StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
                        StylesheetRoot.cpp
  Log:
  Clear out transient objects in endDocument().  This closes any files that may 
have been opened.
  
  Revision  Changes    Path
  1.53      +53 -39    
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- StylesheetExecutionContextDefault.cpp     2001/01/26 22:03:11     1.52
  +++ StylesheetExecutionContextDefault.cpp     2001/01/29 02:30:31     1.53
  @@ -758,8 +758,9 @@
        // resolveTopLevelParams().
        popContextMarker();
   
  -     // Clear any cached XPaths...
  -     clearXPathCache();
  +     cleanUpTransients();
  +
  +     setFormatterListener(0);
   }
   
   
  @@ -1290,50 +1291,16 @@
   void
   StylesheetExecutionContextDefault::reset()
   {
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  -
        assert(m_elementRecursionStack.size() == 0);
   
        m_variablesStack.reset();
   
        m_xsltProcessor.reset();
  -
  -     for_each(m_formatterListeners.begin(),
  -                      m_formatterListeners.end(),
  -                      DeleteFunctor<FormatterListener>());
   
  -     m_formatterListeners.clear();
  -
  -     for_each(m_printWriters.begin(),
  -                      m_printWriters.end(),
  -                      DeleteFunctor<PrintWriter>());
  -
  -     m_printWriters.clear();
  -
  -     for_each(m_outputStreams.begin(),
  -                      m_outputStreams.end(),
  -                      DeleteFunctor<XalanOutputStream>());
  +     // Just in case endDocument() was not called,
  +     // clean things up...
  +     cleanUpTransients();
   
  -     m_outputStreams.clear();
  -
  -     // Clean up the key table vector
  -     for_each(m_keyTables.begin(),
  -                      m_keyTables.end(),
  -                      makeMapValueDeleteFunctor(m_keyTables));
  -
  -     m_keyTables.clear();
  -
  -     assert(m_matchPatternCache.size() == 0);
  -
  -     // Destroy the source tree factory, which
  -     // will destroy all result tree fragment nodes
  -     // that were generated...
  -     m_sourceTreeResultTreeFactory.reset();
  -
  -     m_countersTable.reset();
  -
        // Reset the default execution context...
        m_xpathExecutionContextDefault.reset();
   }
  @@ -1955,4 +1922,51 @@
   
        // Add the XPath with the current clock
        m_matchPatternCache.insert(XPathCacheMapType::value_type(pattern, 
XPathCacheEntry(theXPath, addClock)));
  +}
  +
  +
  +
  +void
  +StylesheetExecutionContextDefault::cleanUpTransients()
  +{
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::for_each;
  +#endif
  +
  +     for_each(m_formatterListeners.begin(),
  +                      m_formatterListeners.end(),
  +                      DeleteFunctor<FormatterListener>());
  +
  +     m_formatterListeners.clear();
  +
  +     for_each(m_printWriters.begin(),
  +                      m_printWriters.end(),
  +                      DeleteFunctor<PrintWriter>());
  +
  +     m_printWriters.clear();
  +
  +     for_each(m_outputStreams.begin(),
  +                      m_outputStreams.end(),
  +                      DeleteFunctor<XalanOutputStream>());
  +
  +     m_outputStreams.clear();
  +
  +     // Clean up the key table vector
  +     for_each(m_keyTables.begin(),
  +                      m_keyTables.end(),
  +                      makeMapValueDeleteFunctor(m_keyTables));
  +
  +     m_keyTables.clear();
  +
  +     // Destroy the source tree factory, which
  +     // will destroy all result tree fragment nodes
  +     // that were generated...
  +     m_sourceTreeResultTreeFactory.reset();
  +
  +     m_countersTable.reset();
  +
  +     // Clear any cached XPaths...
  +     clearXPathCache();
  +
  +     assert(m_matchPatternCache.size() == 0);
   }
  
  
  
  1.47      +6 -0      
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- StylesheetExecutionContextDefault.hpp     2001/01/26 22:03:13     1.46
  +++ StylesheetExecutionContextDefault.hpp     2001/01/29 02:30:31     1.47
  @@ -856,6 +856,12 @@
                        const XPath*                    theXPath);
   
   
  +     /**
  +      * Clean up anything that was created for use only during the 
transformation.
  +      */
  +     void
  +     cleanUpTransients();
  +
        XPathExecutionContextDefault    m_xpathExecutionContextDefault;
   
        // $$ ToDo: Try to remove this dependency, and rely only on 
XSLTProcessor...
  
  
  
  1.34      +5 -2      xml-xalan/c/src/XSLT/StylesheetRoot.cpp
  
  Index: StylesheetRoot.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetRoot.cpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- StylesheetRoot.cpp        2000/12/01 22:11:19     1.33
  +++ StylesheetRoot.cpp        2001/01/29 02:30:31     1.34
  @@ -201,7 +201,7 @@
        executionContext.resetCurrentState(sourceTree, sourceTree);
   
        executionContext.setRootDocument(sourceTree);
  -             
  +
        if(executionContext.doDiagnosticsOutput())
        {
                
executionContext.diag(StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("=============================")));
  @@ -229,6 +229,9 @@
        // occurs from here.
        rootRule->execute(executionContext, sourceTree, sourceTree, 
QNameByReference());
   
  +     // At this point, anything transient during the tranformation
  +     // may have been deleted, so we may not refer to anything the
  +     // execution context may have created for us.
        executionContext.endDocument();
   
   #if defined(XALAN_VQ_SPECIAL_TRACE)
  @@ -349,7 +352,7 @@
        {
                if (outputTarget.getDocument() != 0)
                {
  -                             flistener = 
executionContext.createFormatterToDOM(outputTarget.getDocument(), 0);
  +                     flistener = 
executionContext.createFormatterToDOM(outputTarget.getDocument(), 0);
                }
                else if (outputTarget.getDocumentFragment() != 0)
                {
  
  
  

Reply via email to