Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XalanTransformer.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 1999-2004 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #if !defined(XALANTRANSFORMER_HEADER_GUARD)
00017 #define XALANTRANSFORMER_HEADER_GUARD
00018 
00019 
00020 
00021 // Base include file.  Must be first.
00022 #include <xalanc/XalanTransformer/XalanTransformerDefinitions.hpp>
00023 
00024 
00025 
00026 #include <cassert>
00027 #if defined(XALAN_CLASSIC_IOSTREAMS)
00028 class ostream;
00029 #else
00030 #include <iosfwd>
00031 #endif
00032 #include <algorithm>
00033 
00034 
00035 
00036 #include <xalanc/Include/XalanVector.hpp>
00037 
00038 
00039 
00040 #include <xalanc/XPath/XalanQNameByValue.hpp>
00041 
00042 
00043 
00044 #include <xalanc/XSLT/XSLTInputSource.hpp>
00045 #include <xalanc/XSLT/XSLTResultTarget.hpp>
00046 
00047 
00048 
00049 XALAN_DECLARE_XERCES_CLASS(EntityResolver)
00050 XALAN_DECLARE_XERCES_CLASS(ErrorHandler)
00051 
00052 
00053 
00054 XALAN_CPP_NAMESPACE_BEGIN
00055 
00056 
00057 
00058 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver   EntityResolverType;
00059 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler     ErrorHandlerType;
00060 
00061 
00062 
00063 class Function;
00064 class StylesheetExecutionContextDefault;
00065 class ProblemListener;
00066 class TraceListener;
00067 class XSLTInit;
00068 class XalanDocumentBuilder;
00069 class XalanCompiledStylesheet;
00070 class XalanParsedSource;
00071 class XalanTransformerOutputStream;
00072 
00073 
00074 
00081 class XALAN_TRANSFORMER_EXPORT XalanTransformer
00082 {
00083 
00084 public:
00085     
00086 #if defined(XALAN_NO_STD_NAMESPACE)
00087     typedef ostream         StreamType;
00088 #else
00089     typedef std::ostream    StreamType;
00090 #endif
00091 
00092     XalanTransformer(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
00093 
00094     virtual
00095     ~XalanTransformer();
00096 
00097     MemoryManagerType& 
00098     getMemoryManager()
00099     {
00100         return m_memoryManager;
00101     }
00102 
00103     const MemoryManagerType& 
00104     getMemoryManager() const
00105     {
00106         return m_memoryManager;
00107     }
00108 
00117     static void
00118     initialize(MemoryManagerType&  theManager = XalanMemMgrs::getDefaultXercesMemMgr());
00119 
00132     static void
00133     terminate();
00134 
00153     static void
00154     ICUCleanUp();
00155 
00156 
00157     static void
00158     ICUStartUp(MemoryManagerType&  theManager = XalanMemMgrs::getDefaultXercesMemMgr());
00159 
00169     int
00170     transform(
00171             const XalanParsedSource&    theParsedXML, 
00172             const XSLTInputSource&      theStylesheetSource,
00173             const XSLTResultTarget&     theResultTarget)
00174     {
00175         return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget);
00176     }
00177 
00187     int
00188     transform(
00189             const XalanParsedSource&        theParsedXML,
00190             const XalanCompiledStylesheet*  theCompiledStylesheet,
00191             const XSLTResultTarget&         theResultTarget)
00192     {
00193         assert(theCompiledStylesheet != 0);
00194 
00195         return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget);
00196     }
00197 
00207     int
00208     transform(
00209             const XalanParsedSource&    theParsedXML,                
00210             const XSLTResultTarget&     theResultTarget)
00211     {
00212         assert(s_emptyInputSource != 0);
00213 
00214         return transform(theParsedXML, *s_emptyInputSource, theResultTarget);
00215     }
00216 
00228     int
00229     transform(
00230             const XSLTInputSource&      theInputSource,
00231             const XSLTInputSource&      theStylesheetSource,
00232             const XSLTResultTarget&     theResultTarget);
00233 
00244     int
00245     transform(
00246             const XSLTInputSource&      theInputSource,
00247             const XSLTResultTarget&     theResultTarget)
00248     {
00249         assert(s_emptyInputSource != 0);
00250 
00251         return transform(
00252                         theInputSource, 
00253                         *s_emptyInputSource,
00254                         theResultTarget);
00255     }
00256 
00275     int
00276     transform(
00277             const XSLTInputSource&      theInputSource, 
00278             const XSLTInputSource&      theStylesheetSource,
00279             void*                       theOutputHandle, 
00280             XalanOutputHandlerType      theOutputHandler,
00281             XalanFlushHandlerType       theFlushHandler = 0);
00282     
00294     int
00295     transform(
00296             const XSLTInputSource&          theInputSource, 
00297             const XalanCompiledStylesheet*  theCompiledStylesheet,
00298             const XSLTResultTarget&         theResultTarget);
00299  
00318     int
00319     transform(
00320             const XalanParsedSource&        theParsedSource,
00321             const XalanCompiledStylesheet*  theCompiledStylesheet,
00322             void*                           theOutputHandle,
00323             XalanOutputHandlerType          theOutputHandler,
00324             XalanFlushHandlerType           theFlushHandler = 0);
00325 
00343     int
00344     transform(
00345             const XSLTInputSource&      theInputSource,
00346             void*                       theOutputHandle,
00347             XalanOutputHandlerType      theOutputHandler,
00348             XalanFlushHandlerType       theFlushHandler = 0);
00349 
00362     int
00363     compileStylesheet(
00364             const XSLTInputSource&              theStylesheetSource,
00365             const XalanCompiledStylesheet*&     theCompiledStylesheet);
00366 
00374     int
00375     destroyStylesheet(const XalanCompiledStylesheet*    theStylesheet);
00376 
00390     int
00391     parseSource(
00392             const XSLTInputSource&      theInputSource,
00393             const XalanParsedSource*&   theParsedSource,
00394             bool                        useXercesDOM = false);
00395 
00402     int
00403     destroyParsedSource(const XalanParsedSource*    theParsedSource);
00404 
00415     XalanDocumentBuilder*
00416     createDocumentBuilder(const XalanDOMString&     theURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr()));
00417 
00425     void
00426     destroyDocumentBuilder(XalanDocumentBuilder*    theDocumentBuilder);
00427 
00435     void
00436     installExternalFunction(
00437             const XalanDOMString&   theNamespace,
00438             const XalanDOMString&   functionName,
00439             const Function&         function);
00440 
00448     static void
00449     installExternalFunctionGlobal(
00450             const XalanDOMString&   theNamespace,
00451             const XalanDOMString&   functionName,
00452             const Function&         function);
00453 
00460     void
00461     uninstallExternalFunction(
00462             const XalanDOMString&   theNamespace,
00463             const XalanDOMString&   functionName);
00464 
00471     static void
00472     uninstallExternalFunctionGlobal(
00473             const XalanDOMString&   theNamespace,
00474             const XalanDOMString&   functionName);
00475 
00483     void
00484     setStylesheetParam(
00485             const XalanDOMString&   key,
00486             const XalanDOMString&   expression);
00487 
00495     void
00496     setStylesheetParam(
00497             const char*     key,
00498             const char*     expression);
00499 
00507     void
00508     addTraceListener(TraceListener*     theTraceListener)
00509     {
00510         m_traceListeners.push_back(theTraceListener);
00511     }
00512 
00519     bool
00520     removeTraceListener(TraceListener*  theTraceListener);
00521 
00525     void
00526     removeTraceListeners()
00527     {
00528         m_traceListeners.clear();
00529     }
00530 
00537     bool
00538     getUseValidation() const
00539     {
00540         return m_useValidation;
00541     }
00542 
00549     void
00550     setUseValidation(bool   fValue)
00551     {
00552         m_useValidation = fValue;
00553     }
00554 
00560     EntityResolverType*
00561     getEntityResolver() const
00562     {
00563         return m_entityResolver;
00564     }
00565 
00575     void
00576     setEntityResolver(EntityResolverType*   theResolver)
00577     {
00578         m_entityResolver = theResolver;
00579     }
00580 
00586     ErrorHandlerType*
00587     getErrorHandler() const
00588     {
00589         return m_errorHandler;
00590     }
00591 
00597     void
00598     setErrorHandler(ErrorHandlerType*   theErrorHandler)
00599     {
00600         m_errorHandler = theErrorHandler;
00601     }
00602 
00609     const XalanDOMChar*
00610     getExternalSchemaLocation() const
00611     {
00612         return m_externalSchemaLocation.empty() == true ? 0 : m_externalSchemaLocation.c_str();
00613     }
00614 
00621     void
00622     setExternalSchemaLocation(const XalanDOMChar*   location)
00623     {
00624         assert(location != 0);
00625 
00626         m_externalSchemaLocation = location;
00627     }
00628 
00635     const XalanDOMChar*
00636     getExternalNoNamespaceSchemaLocation() const
00637     {
00638         return m_externalNoNamespaceSchemaLocation.empty() == true ? 0 : m_externalNoNamespaceSchemaLocation.c_str();
00639     }
00640 
00647     void
00648     setExternalNoNamespaceSchemaLocation(const XalanDOMChar*    location)
00649     {
00650         assert(location != 0);
00651 
00652         m_externalNoNamespaceSchemaLocation = location;
00653     }
00654 
00661     bool
00662     getPoolAllTextNodes() const
00663     {
00664         return m_poolAllTextNodes;
00665     }
00666 
00675     void
00676     setPoolAllTextNodes(bool    fPool)
00677     {
00678         m_poolAllTextNodes = fPool;
00679     }
00680 
00686     ProblemListener*
00687     getProblemListener() const
00688     {
00689         return  m_problemListener;
00690     }
00691 
00697     void
00698     setProblemListener(ProblemListener*     theProblemListener)
00699     {
00700         m_problemListener = theProblemListener;
00701     }
00702 
00709     const char*
00710     getLastError() const
00711     {
00712         assert(m_errorMessage.empty() == false);
00713 
00714         return &m_errorMessage[0]; 
00715     }
00716 
00723     const XalanDOMString&
00724     getOutputEncoding() const
00725     {
00726         return m_outputEncoding;
00727     }
00728 
00737     void
00738     setOutputEncoding(const XalanDOMString&     theEncoding)
00739     {
00740         m_outputEncoding = theEncoding;
00741     }
00742 
00748     int
00749     getIndent() const;
00750 
00756     void
00757     setIndent(int   indentAmount);
00758 
00762     enum eEscapeURLs
00763     {
00764         eEscapeURLsDefault,     // Use the value in the stylesheet
00765         eEscapeURLsNo,          // Don't escape URLs
00766         eEscapeURLsYes          // Escape URLs
00767     };
00768 
00776     eEscapeURLs
00777     getEscapeURLs() const;
00778 
00786     void
00787     setEscapeURLs(eEscapeURLs   value);
00788 
00793     enum eOmitMETATag
00794     {
00795         eOmitMETATagDefault,    // Use the value in the stylesheet
00796         eOmitMETATagNo,         // Don't omit the META tag
00797         eOmitMETATagYes         // Omit the META tag
00798     };
00799 
00807     eOmitMETATag
00808     getOmitMETATag() const;
00809 
00817     void
00818     setOmitMETATag(eOmitMETATag     value);
00819 
00828     void
00829     setWarningStream(StreamType*    theStream)
00830     {
00831         m_warningStream = theStream;
00832     }
00833 
00839     StreamType*
00840     getWarningStream() const
00841     {
00842         return m_warningStream;
00843     }
00844 
00845     typedef XalanVector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType;
00846     typedef XalanVector<const XalanParsedSource*>       ParsedSourcePtrVectorType;
00847     typedef XALAN_STD_QUALIFIER pair<XalanDOMString*, XalanDOMString*>      ParamPairType;
00848     typedef XalanVector<ParamPairType>                  ParamPairVectorType;
00849     typedef XALAN_STD_QUALIFIER pair<XalanQNameByValue*, Function*>         FunctionPairType;
00850     typedef XalanVector<FunctionPairType>               FunctionParamPairVectorType;
00851     typedef XalanVector<TraceListener*>                 TraceListenerVectorType;
00852 
00853     class EnsureFunctionsInstallation
00854     {
00855     public:
00856         
00857         EnsureFunctionsInstallation(MemoryManagerType& theManager) : 
00858           m_memoryManagement(theManager),
00859           m_release(false)
00860         {    
00861         }
00862 
00863         ~EnsureFunctionsInstallation();
00864 
00865         void
00866         install();
00867 
00868         void
00869         release()
00870         {
00871             m_release = true;
00872         }
00873 
00874     private:
00875         MemoryManagerType& m_memoryManagement;
00876 
00877         bool m_release;
00878     };
00879 
00880     class EnsureDestroyParsedSource
00881     {
00882     public:
00883 
00884         EnsureDestroyParsedSource(
00885                 XalanTransformer&           theTransformer,
00886                 const XalanParsedSource*    theParsedSource) :
00887             m_transformer(theTransformer),
00888             m_parsedSource(theParsedSource)
00889         {
00890         }
00891 
00892         ~EnsureDestroyParsedSource()
00893         {
00894             m_transformer.destroyParsedSource(m_parsedSource);
00895         }
00896 
00897     private:
00898 
00899         XalanTransformer&               m_transformer;
00900 
00901         const XalanParsedSource* const  m_parsedSource;
00902     };
00903 
00904     struct EnsureDestroyCompiledStylesheet
00905     {
00906         EnsureDestroyCompiledStylesheet(
00907                 XalanTransformer&               theTransformer,
00908                 const XalanCompiledStylesheet*  theCompiledStylesheet) :
00909             m_transformer(theTransformer),
00910             m_compiledStylesheet(theCompiledStylesheet)
00911         {
00912         }
00913 
00914         ~EnsureDestroyCompiledStylesheet()
00915         {
00916             m_transformer.destroyStylesheet(m_compiledStylesheet);
00917         }
00918 
00919     private:
00920 
00921         XalanTransformer&                       m_transformer;
00922 
00923         const XalanCompiledStylesheet* const    m_compiledStylesheet;
00924     };
00925 
00926     struct EnsureDestroyDocumentBuilder
00927     {
00928         EnsureDestroyDocumentBuilder(
00929                 XalanTransformer&       theTransformer,
00930                 XalanDocumentBuilder*   theDocumentBuilder) :
00931             m_transformer(theTransformer),
00932             m_documentBuilder(theDocumentBuilder)
00933         {
00934         }
00935 
00936         ~EnsureDestroyDocumentBuilder()
00937         {
00938             m_transformer.destroyDocumentBuilder(m_documentBuilder);
00939         }
00940 
00941     private:
00942 
00943         XalanTransformer&           m_transformer;
00944 
00945         XalanDocumentBuilder* const m_documentBuilder;
00946     };
00947     template <class T>
00948 #if defined(XALAN_NO_STD_NAMESPACE)
00949     struct DeleteParamPairFunctor : public unary_function<T&, void>
00950 #else
00951     struct DeleteParamPairFunctor : public std::unary_function<T&, void>
00952 #endif
00953     {
00954 #if defined(XALAN_NO_STD_NAMESPACE)
00955         typedef unary_function<T&, void>    BaseClassType;
00956 #else
00957         typedef std::unary_function<T&, void>   BaseClassType;
00958 #endif
00959 
00960         typedef typename BaseClassType::result_type     result_type;
00961         typedef typename BaseClassType::argument_type   argument_type;
00962 
00963         DeleteParamPairFunctor(MemoryManagerType&      theManager) :
00964         m_memoryManager(theManager)
00965         {
00966         }
00967 
00968         template<class PtrT>
00969     void
00970         deletePtr(PtrT* ptr)const
00971         {
00972             ptr->~PtrT();
00973         }
00974 
00980         result_type
00981             operator()(argument_type    thePair) const
00982         {
00983             T&  tmpPair = const_cast<T&>(thePair);
00984 
00985             if (tmpPair.first != 0)
00986             {
00987                 deletePtr(tmpPair.first);
00988                 
00989                 m_memoryManager.deallocate((void*)tmpPair.first);
00990             }
00991 
00992             if (tmpPair.second != 0)
00993             {
00994                 deletePtr(tmpPair.second);
00995                 
00996                 m_memoryManager.deallocate((void*)tmpPair.second);
00997             }            
00998 
00999             
01000         }
01001 
01002     private:
01003 
01004         MemoryManagerType& m_memoryManager;
01005 
01006     };
01007 protected:
01008 
01009 private:
01010 
01011     void
01012     reset();
01013 
01014     class EnsureReset
01015     {
01016     public:
01017 
01018         EnsureReset(XalanTransformer&   theTransformer) :
01019             m_transformer(theTransformer)
01020         {
01021         }
01022 
01023         ~EnsureReset();
01024 
01025     private:
01026 
01027         XalanTransformer&   m_transformer;
01028     };
01029 
01030     friend class EnsureReset;
01031 
01032     int
01033     doTransform(
01034             const XalanParsedSource&        theParsedXML, 
01035             const XalanCompiledStylesheet*  theCompiledStylesheet,
01036             const XSLTInputSource*          theStylesheetSource,
01037             const XSLTResultTarget&         theResultTarget);
01038 
01039 
01040     // Data members...
01041     MemoryManagerType&                      m_memoryManager;
01042 
01043     CompiledStylesheetPtrVectorType         m_compiledStylesheets;
01044 
01045     ParsedSourcePtrVectorType               m_parsedSources;
01046 
01047     ParamPairVectorType                     m_paramPairs;
01048 
01049     FunctionParamPairVectorType             m_functionPairs;
01050 
01051     TraceListenerVectorType                 m_traceListeners;
01052 
01053     CharVectorType                          m_errorMessage;
01054 
01055     bool                                    m_useValidation;
01056 
01057     EntityResolverType*                     m_entityResolver;
01058 
01059     ErrorHandlerType*                       m_errorHandler;
01060 
01061     XalanDOMString                          m_externalSchemaLocation;
01062 
01063     XalanDOMString                          m_externalNoNamespaceSchemaLocation;
01064 
01065     ProblemListener*                        m_problemListener;
01066 
01067     StreamType*                             m_warningStream;
01068 
01069     XalanDOMString                          m_outputEncoding;
01070 
01071     bool                                    m_poolAllTextNodes;
01072 
01073     // This should always be the latest data member!!!
01074     StylesheetExecutionContextDefault*      m_stylesheetExecutionContext;
01075 
01076     static const XSLTInputSource*           s_emptyInputSource;
01077 
01078     static const XSLTInit*                  s_xsltInit;
01079 };
01080 
01081 
01082 
01083 XALAN_CPP_NAMESPACE_END
01084 
01085 
01086 
01087 #endif  // XALANTRANSFORMER_HEADER_GUARD

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo