dbertoni    01/11/06 20:04:28

  Modified:    c/src/XalanTransformer XalanCompiledStylesheetDefault.cpp
                        XalanCompiledStylesheetDefault.hpp
                        XalanDefaultParsedSource.cpp
                        XalanDefaultParsedSource.hpp XalanTransformer.cpp
                        XalanTransformer.hpp XercesDOMParsedSource.cpp
                        XercesDOMParsedSource.hpp
  Log:
  Enable the use of EntityResolvers and ErrorHandlers.
  
  Revision  Changes    Path
  1.2       +66 -4     
xml-xalan/c/src/XalanTransformer/XalanCompiledStylesheetDefault.cpp
  
  Index: XalanCompiledStylesheetDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XalanCompiledStylesheetDefault.cpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanCompiledStylesheetDefault.cpp        2001/06/07 19:10:03     1.1
  +++ XalanCompiledStylesheetDefault.cpp        2001/11/07 04:04:27     1.2
  @@ -58,20 +58,82 @@
   
   
   
  +#include <XMLSupport/XMLParserLiaison.hpp>
  +
  +
  +
  +class SetAndRestoreHandlers
  +{
  +public:
  +
  +     SetAndRestoreHandlers(
  +                     XMLParserLiaison&       theParserLiaison,
  +                     ErrorHandler*           theErrorHandler,
  +                     EntityResolver*         theEntityResolver) :
  +             m_parserLiaison(theParserLiaison),
  +             m_errorHandler(theParserLiaison.getErrorHandler()),
  +             m_entityResolver(theParserLiaison.getEntityResolver())
  +     {
  +             theParserLiaison.setErrorHandler(theErrorHandler);
  +
  +             theParserLiaison.setEntityResolver(theEntityResolver);
  +     }
  +
  +     ~SetAndRestoreHandlers()
  +     {
  +             m_parserLiaison.setEntityResolver(m_entityResolver);
  +
  +             m_parserLiaison.setErrorHandler(m_errorHandler);
  +     }
  +
  +private:
  +
  +     XMLParserLiaison&               m_parserLiaison;
  +
  +     ErrorHandler* const             m_errorHandler;
  +
  +     EntityResolver* const   m_entityResolver;
  +};
  +
  +
  +
  +
  +inline const StylesheetRoot*
  +compileStylesheet(
  +                     const XSLTInputSource&                                  
theStylesheetSource,
  +                     XSLTEngineImpl&                                         
        theProcessor,
  +                     StylesheetConstructionContextDefault&   
theConstructionContext,
  +                     ErrorHandler*                                           
        theErrorHandler,
  +                     EntityResolver*                                         
        theEntityResolver)
  +{
  +     const SetAndRestoreHandlers             theSetAndRestore(
  +                     theProcessor.getXMLParserLiaison(),
  +                     theErrorHandler,
  +                     theEntityResolver);
  +
  +     return theProcessor.processStylesheet(theStylesheetSource, 
theConstructionContext);
  +}
  +
  +
  +
   XalanCompiledStylesheetDefault::XalanCompiledStylesheetDefault(
                        const XSLTInputSource&                          
theStylesheetSource,
                        XSLTProcessorEnvSupportDefault&         
theXSLTProcessorEnvSupport,
  -                     XSLTEngineImpl&                                         
theProcessor):
  +                     XSLTEngineImpl&                                         
theProcessor,
  +                     ErrorHandler*                                           
theErrorHandler,
  +                     EntityResolver*                                         
theEntityResolver):
        XalanCompiledStylesheet(),
        m_stylesheetXPathFactory(),
        m_stylesheetConstructionContext(
                                theProcessor,
                                theXSLTProcessorEnvSupport,
                                m_stylesheetXPathFactory),
  -     m_stylesheetRoot(
  -                             theProcessor.processStylesheet(
  +     m_stylesheetRoot(compileStylesheet(
                                theStylesheetSource,
  -                             m_stylesheetConstructionContext))
  +                             theProcessor,
  +                             m_stylesheetConstructionContext,
  +                             theErrorHandler,
  +                             theEntityResolver))
   {
   }
   
  
  
  
  1.2       +9 -2      
xml-xalan/c/src/XalanTransformer/XalanCompiledStylesheetDefault.hpp
  
  Index: XalanCompiledStylesheetDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XalanCompiledStylesheetDefault.hpp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XalanCompiledStylesheetDefault.hpp        2001/06/07 19:10:03     1.1
  +++ XalanCompiledStylesheetDefault.hpp        2001/11/07 04:04:27     1.2
  @@ -81,6 +81,11 @@
   
   
   
  +class EntityResolver;
  +class ErrorHandler;
  +
  +
  +
   class XALAN_TRANSFORMER_EXPORT XalanCompiledStylesheetDefault : public 
XalanCompiledStylesheet
   {
   public:
  @@ -88,7 +93,9 @@
        XalanCompiledStylesheetDefault(
                        const XSLTInputSource&                          
theStylesheetSource,
                        XSLTProcessorEnvSupportDefault&         
theXSLTProcessorEnvSupport,
  -                     XSLTEngineImpl&                                         
theProcessor);
  +                     XSLTEngineImpl&                                         
theProcessor,
  +                     ErrorHandler*                                           
theErrorHandler = 0,
  +                     EntityResolver*                                         
theEntityResolver = 0);
   
        virtual
        ~XalanCompiledStylesheetDefault();
  @@ -102,7 +109,7 @@
   
        StylesheetConstructionContextDefault    m_stylesheetConstructionContext;
   
  -     const StylesheetRoot*                                   
m_stylesheetRoot;
  +     const StylesheetRoot* const                             
m_stylesheetRoot;
   };
   
   
  
  
  
  1.6       +5 -1      
xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.cpp
  
  Index: XalanDefaultParsedSource.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XalanDefaultParsedSource.cpp      2001/09/06 18:41:11     1.5
  +++ XalanDefaultParsedSource.cpp      2001/11/07 04:04:27     1.6
  @@ -167,13 +167,17 @@
   
   XalanDefaultParsedSource::XalanDefaultParsedSource(
                        const XSLTInputSource&  theInputSource,
  -                     bool                                    fValidate) :
  +                     bool                                    fValidate,
  +                     ErrorHandler*                   theErrorHandler,
  +                     EntityResolver*                 theEntityResolver) :
        XalanParsedSource(),
        m_domSupport(),
        m_parserLiaison(m_domSupport),
        m_parsedSource(0)
   {
        m_parserLiaison.setUseValidation(fValidate);
  +     m_parserLiaison.setEntityResolver(theEntityResolver);
  +     m_parserLiaison.setErrorHandler(theErrorHandler);
   
        m_parsedSource = 
m_parserLiaison.mapDocument(m_parserLiaison.parseXMLStream(theInputSource));
        assert(m_parsedSource != 0);
  
  
  
  1.6       +5 -1      
xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.hpp
  
  Index: XalanDefaultParsedSource.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XalanDefaultParsedSource.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XalanDefaultParsedSource.hpp      2001/09/06 18:41:11     1.5
  +++ XalanDefaultParsedSource.hpp      2001/11/07 04:04:27     1.6
  @@ -77,6 +77,8 @@
   
   
   
  +class EntityResolver;
  +class ErrorHandler;
   class XalanSourceTreeDocument;
   
   
  @@ -148,7 +150,9 @@
   
        XalanDefaultParsedSource(
                        const XSLTInputSource&  theInputSource,
  -                     bool                                    fValidate = 
false);
  +                     bool                                    fValidate = 
false,
  +                     ErrorHandler*                   theErrorHandler = 0,
  +                     EntityResolver*                 theEntityResolver = 0);
   
        virtual
        ~XalanDefaultParsedSource();
  
  
  
  1.39      +14 -2     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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XalanTransformer.cpp      2001/10/30 04:01:36     1.38
  +++ XalanTransformer.cpp      2001/11/07 04:04:27     1.39
  @@ -132,6 +132,8 @@
        m_functionPairs(),
        m_errorMessage(1, '\0'),
        m_useValidation(false),
  +     m_entityResolver(0),
  +     m_errorHandler(0),
        m_stylesheetExecutionContext(new StylesheetExecutionContextDefault)
   {
   #if defined(XALAN_USE_ICU)
  @@ -935,11 +937,21 @@
   
                if(useXercesDOM == true)
                {
  -                     theParsedSource = new 
XercesDOMParsedSource(theInputSource, m_useValidation);
  +                     theParsedSource =
  +                             new XercesDOMParsedSource(
  +                                             theInputSource,
  +                                             m_useValidation,
  +                                             m_errorHandler,
  +                                             m_entityResolver);
                }
                else
                {
  -                     theParsedSource = new 
XalanDefaultParsedSource(theInputSource, m_useValidation);
  +                     theParsedSource =
  +                             new XalanDefaultParsedSource(
  +                                             theInputSource,
  +                                             m_useValidation,
  +                                             m_errorHandler,
  +                                             m_entityResolver);
                }
   
                // Store it in a vector.
  
  
  
  1.35      +54 -0     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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- XalanTransformer.hpp      2001/10/30 04:01:36     1.34
  +++ XalanTransformer.hpp      2001/11/07 04:04:27     1.35
  @@ -77,6 +77,8 @@
   
   
   
  +class EntityResolver;
  +class ErrorHandler;
   class Function;
   class StylesheetExecutionContextDefault;
   class XSLTInit;
  @@ -447,6 +449,54 @@
        }
   
        /**
  +      * This method returns the installed entity resolver.
  +      *
  +      * @return The pointer to the installed entity resolver object.
  +      */
  +     EntityResolver*
  +     getEntityResolver() const
  +     {
  +             return m_entityResolver;
  +     }
  +
  +     /**
  +      * This method installs the user-specified entity resolver.
  +      * It allows applications to trap and redirect calls to
  +      * external entities.
  +      *
  +      * @param handler A pointer to the entity resolver to be called
  +      *                         when the parser comes across references to
  +      *                         entities in the XML file.
  +      */
  +     void
  +     setEntityResolver(EntityResolver*       theResolver)
  +     {
  +             m_entityResolver = theResolver;
  +     }
  +
  +     /**
  +      * This method returns the installed error handler.
  +      *
  +      * @return The pointer to the installed error handler object.
  +      */
  +     ErrorHandler*
  +     getErrorHandler() const
  +     {
  +             return m_errorHandler;
  +     }
  +
  +     /**
  +      * This method installs the user-specified error handler.
  +      *
  +      * @param handler A pointer to the error handler to be called upon 
error.
  +      */
  +     void
  +     setErrorHandler(ErrorHandler*   theErrorHandler)
  +     {
  +             m_errorHandler = theErrorHandler;
  +     }
  +
  +     /**
         * Returns the last error that occurred as a 
         * result of calling transform. 
         *
  @@ -591,6 +641,10 @@
        CharVectorType                                                  
m_errorMessage;
   
        bool                                                                    
m_useValidation;
  +
  +     EntityResolver*                                                 
m_entityResolver;
  +
  +     ErrorHandler*                                                   
m_errorHandler;
   
        // This should always be the latest data member!!!
        StylesheetExecutionContextDefault*              
m_stylesheetExecutionContext;
  
  
  
  1.6       +5 -1      
xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.cpp
  
  Index: XercesDOMParsedSource.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XercesDOMParsedSource.cpp 2001/09/06 18:41:11     1.5
  +++ XercesDOMParsedSource.cpp 2001/11/07 04:04:27     1.6
  @@ -93,12 +93,16 @@
   
   XercesDOMParsedSource::XercesDOMParsedSource(
                        const XSLTInputSource&  theInputSource,
  -                     bool                                    fValidate):
  +                     bool                                    fValidate,
  +                     ErrorHandler*                   theErrorHandler,
  +                     EntityResolver*                 theEntityResolver):
        XalanParsedSource(),
        m_parserLiaison(),
        m_parsedSource(0)
   {
        m_parserLiaison.setUseValidation(fValidate);
  +     m_parserLiaison.setEntityResolver(theEntityResolver);
  +     m_parserLiaison.setErrorHandler(theErrorHandler);
   
        m_parsedSource = m_parserLiaison.parseXMLStream(theInputSource);
        assert(m_parsedSource != 0);
  
  
  
  1.6       +8 -1      
xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.hpp
  
  Index: XercesDOMParsedSource.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XalanTransformer/XercesDOMParsedSource.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XercesDOMParsedSource.hpp 2001/09/06 18:41:11     1.5
  +++ XercesDOMParsedSource.hpp 2001/11/07 04:04:27     1.6
  @@ -77,6 +77,11 @@
   
   
   
  +class EntityResolver;
  +class ErrorHandler;
  +
  +
  +
   /**
    * This is designed to allow a XalanTranfomer object to reuse a parsed
    * document. 
  @@ -87,7 +92,9 @@
        
        XercesDOMParsedSource(
                        const XSLTInputSource&  theInputSource,
  -                     bool                                    fValidate = 
false);
  +                     bool                                    fValidate = 
false,
  +                     ErrorHandler*                   theErrorHandler = 0,
  +                     EntityResolver*                 theEntityResolver = 0);
   
        virtual
        ~XercesDOMParsedSource();
  
  
  

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

Reply via email to