dbertoni    02/02/06 11:47:02

  Modified:    c/src/XalanTransformer XalanTransformer.cpp
                        XalanTransformer.hpp
  Log:
  Implemented TraceListener support.
  
  Revision  Changes    Path
  1.41      +59 -13    xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
  
  Index: XalanTransformer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- XalanTransformer.cpp      7 Dec 2001 20:14:07 -0000       1.40
  +++ XalanTransformer.cpp      6 Feb 2002 19:47:02 -0000       1.41
  @@ -129,6 +129,7 @@
        m_parsedSources(),
        m_paramPairs(),
        m_functionPairs(),
  +     m_traceListeners(),
        m_errorMessage(1, '\0'),
        m_useValidation(false),
        m_entityResolver(0),
  @@ -163,8 +164,6 @@
                delete m_functionPairs[i].second;
        }
   
  -     m_functionPairs.clear();
  -
        delete m_stylesheetExecutionContext;
   }
   
  @@ -245,16 +244,34 @@
   
   
   
  +static void
  +addTraceListeners(
  +                               const XalanTransformer::TraceListenerVectorType&     
 theTraceListeners,
  +                               XSLTEngineImpl&                                      
                                 theEngine)
  +{
  +     if (theTraceListeners.size() != 0)
  +     {
  +             typedef XalanTransformer::TraceListenerVectorType       
TraceListenerVectorType;
  +
  +             TraceListenerVectorType::const_iterator         theEnd = 
theTraceListeners.end();
  +
  +             for(TraceListenerVectorType::const_iterator i = 
theTraceListeners.begin(); i != theEnd; ++i)
  +             {
  +                     theEngine.addTraceListener(*i);
  +             }
  +
  +             theEngine.setTraceSelects(true);
  +     }
  +}
  +
  +
  +
   int
   XalanTransformer::transform(
        const XalanParsedSource&        theParsedXML, 
        const XSLTInputSource&          theStylesheetSource,
        const XSLTResultTarget&         theResultTarget)
   {
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  -
        int     theResult = 0;
   
        // Clear the error message.
  @@ -272,9 +289,9 @@
                XalanAutoPtr<XalanParsedSourceHelper>   
theHelper(theParsedXML.createHelper());
                assert(theHelper.get() != 0);
   
  -             DOMSupport&                                     theDOMSupport = 
theHelper->getDOMSupport();
  +             DOMSupport&             theDOMSupport = theHelper->getDOMSupport();
   
  -             XMLParserLiaison&                               theParserLiaison = 
theHelper->getParserLiaison();
  +             XMLParserLiaison&       theParserLiaison = 
theHelper->getParserLiaison();
   
                theParserLiaison.setUseValidation(m_useValidation);
   
  @@ -293,6 +310,8 @@
                                theXObjectFactory,
                                theXPathFactory);
   
  +             addTraceListeners(m_traceListeners, theProcessor);
  +
                theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
   
                const XalanDOMString&   theSourceURI = theParsedXML.getURI();
  @@ -433,9 +452,7 @@
                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                        const XSLTResultTarget&                 theResultTarget)
   {
  -#if !defined(XALAN_NO_NAMESPACES)
  -     using std::for_each;
  -#endif
  +     assert(theCompiledStylesheet != 0);
   
        int     theResult = 0;
   
  @@ -454,9 +471,9 @@
                XalanAutoPtr<XalanParsedSourceHelper>   
theHelper(theParsedXML.createHelper());
                assert(theHelper.get() != 0);
   
  -             DOMSupport&                                     theDOMSupport = 
theHelper->getDOMSupport();
  +             DOMSupport&             theDOMSupport = theHelper->getDOMSupport();
   
  -             XMLParserLiaison&                               theParserLiaison = 
theHelper->getParserLiaison();
  +             XMLParserLiaison&       theParserLiaison = 
theHelper->getParserLiaison();
   
                theParserLiaison.setUseValidation(m_useValidation);
   
  @@ -475,6 +492,8 @@
                                theXObjectFactory,
                                theXPathFactory);
   
  +             addTraceListeners(m_traceListeners, theProcessor);
  +
                theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
   
                const XalanDOMString&   theSourceURI = theParsedXML.getURI();
  @@ -1052,6 +1071,33 @@
                        const char*             expression)
   {
        setStylesheetParam(XalanDOMString(key), XalanDOMString(expression));
  +}
  +
  +
  +
  +bool
  +XalanTransformer::removeTraceListener(TraceListener* theTraceListener)
  +{
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::find;
  +#endif
  +
  +     const TraceListenerVectorType::iterator         i =
  +             find(
  +                     m_traceListeners.begin(),
  +                     m_traceListeners.end(),
  +                     theTraceListener);
  +
  +     if (i == m_traceListeners.end())
  +     {
  +             return false;
  +     }
  +     else
  +     {
  +             m_traceListeners.erase(i);
  +
  +             return true;
  +     }
   }
   
   
  
  
  
  1.36      +42 -6     xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp
  
  Index: XalanTransformer.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.hpp,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- XalanTransformer.hpp      7 Nov 2001 04:04:27 -0000       1.35
  +++ XalanTransformer.hpp      6 Feb 2002 19:47:02 -0000       1.36
  @@ -81,6 +81,7 @@
   class ErrorHandler;
   class Function;
   class StylesheetExecutionContextDefault;
  +class TraceListener;
   class XSLTInit;
   class XalanDocumentBuilder;
   class XalanCompiledStylesheet;
  @@ -140,7 +141,7 @@
         * and write the transformation output to the target. 
         *
         * @param theParsedXML                  the parsed input source
  -      * @param theCompiledStylesheet pointer to a compiled stylesheet
  +      * @param theCompiledStylesheet pointer to a compiled stylesheet.  Must not be 
null.
         * @param theResultTarget               output source 
         * @return      0 for success
         */
  @@ -215,7 +216,7 @@
         * node. 
         *
         * @param theInputSource                input source
  -      * @param theCompiledStylesheet pointer to a compiled stylesheet
  +      * @param theCompiledStylesheet pointer to a compiled stylesheet.  Must not be 
null.
         * @param theResultTarget               output source 
         * @return      0 for success
         */
  @@ -237,7 +238,7 @@
         * for more details.
         * 
         * @param theParsedSource               Parsed source instance
  -      * @param theCompiledStylesheet pointer to a compiled stylesheet
  +      * @param theCompiledStylesheet pointer to a compiled stylesheet.  Must not be 
null.
         * @param theOutputHandle               void pointer passed through to 
callback.
         * @param theOutputHandler              a user defined callback function.
         * @param theFlushHandler               An optional user-defined callback 
function.
  @@ -276,7 +277,7 @@
                        XalanFlushHandlerType           theFlushHandler = 0);
   
        /**
  -      * Creates a compeled stylesheet.  The input source can be 
  +      * Creates a compiled stylesheet.  The input source can be 
         * a file name, a stream or a root node.   The XalanTransformer
         * instance owns the XalanCompiledStylesheet instance and will
         * delete it when the XalanTransformer instance goes out of scope,
  @@ -312,7 +313,7 @@
         *
         * @param theInputSource input source
         * @param theParsedSource a reference to a pointer to a XalanParsedSource.
  -      * @param useXercesDOM input use default or xerces dom source tree
  +      * @param useXercesDOM input use default or xerces DOM source tree
         * @return 0 for success 
         */
        int
  @@ -414,7 +415,7 @@
   
        /**
         * Set a top-level stylesheet parameter.  This value can be evaluated via
  -      * xsl:param-variable.
  +      * xsl:param-variable.  These values are cleared after a call to transform().
         *
         * @param key name of the param
         * @param expression expression that will be evaluated
  @@ -425,6 +426,37 @@
                        const char*             expression);
   
        /**
  +      * Add a TraceListener instance.  TraceListeners instances are preserved
  +      * between calls to transform(), so they will be called until they are
  +      * removed.
  +      *
  +      * @param theTraceListener The instance to add.
  +      */
  +     void
  +     addTraceListener(TraceListener*         theTraceListener)
  +     {
  +             m_traceListeners.push_back(theTraceListener);
  +     }
  +
  +     /**
  +      * Remove a TraceListener instance
  +      *
  +      * @param theTraceListener The instance to remove.
  +      * @return true if the instance was removed, false if not.
  +      */
  +     bool
  +     removeTraceListener(TraceListener*      theTraceListener);
  +
  +     /**
  +      * Remove all TraceListener instances.
  +      */
  +     void
  +     removeTraceListeners()
  +     {
  +             m_traceListeners.clear();
  +     }
  +
  +     /**
         * Set a flag to indicate whether or not the source file(s) for the
         * transformation will be validated.
         *
  @@ -528,6 +560,7 @@
        typedef vector<ParamPairType>                                           
ParamPairVectorType;
        typedef pair<XalanQNameByValue, Function*>                      
FunctionPairType;
        typedef vector<FunctionPairType>                                        
FunctionParamPairVectorType;
  +     typedef vector<TraceListener*>                                          
TraceListenerVectorType;
   #else
        typedef std::vector<const XalanCompiledStylesheet*> 
CompiledStylesheetPtrVectorType;
        typedef std::vector<const XalanParsedSource*>           
ParsedSourcePtrVectorType;
  @@ -535,6 +568,7 @@
        typedef std::vector<ParamPairType>                                      
ParamPairVectorType;
        typedef std::pair<XalanQNameByValue, Function*>         FunctionPairType;
        typedef std::vector<FunctionPairType>                           
FunctionParamPairVectorType;
  +     typedef std::vector<TraceListener*>                                     
TraceListenerVectorType;
   #endif
   
        class EnsureDestroyParsedSource
  @@ -637,6 +671,8 @@
        ParamPairVectorType                                     m_paramPairs;
   
        FunctionParamPairVectorType                     m_functionPairs;
  +
  +     TraceListenerVectorType                                 m_traceListeners;
   
        CharVectorType                                                  m_errorMessage;
   
  
  
  

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

Reply via email to