Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.6

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

XalanTransformer.hpp

Go to the documentation of this file.
00001 /*
00002  * The Apache Software License, Version 1.1
00003  *
00004  *
00005  * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights 
00006  * reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer. 
00014  *
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in
00017  *    the documentation and/or other materials provided with the
00018  *    distribution.
00019  *
00020  * 3. The end-user documentation included with the redistribution,
00021  *    if any, must include the following acknowledgment:  
00022  *       "This product includes software developed by the
00023  *        Apache Software Foundation (http://www.apache.org/)."
00024  *    Alternately, this acknowledgment may appear in the software itself,
00025  *    if and wherever such third-party acknowledgments normally appear.
00026  *
00027  * 4. The names "Xalan" and "Apache Software Foundation" must
00028  *    not be used to endorse or promote products derived from this
00029  *    software without prior written permission. For written 
00030  *    permission, please contact apache@apache.org.
00031  *
00032  * 5. Products derived from this software may not be called "Apache",
00033  *    nor may "Apache" appear in their name, without prior written
00034  *    permission of the Apache Software Foundation.
00035  *
00036  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00038  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00039  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
00040  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00041  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00042  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00043  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00044  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00045  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00046  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00047  * SUCH DAMAGE.
00048  * ====================================================================
00049  *
00050  * This software consists of voluntary contributions made by many
00051  * individuals on behalf of the Apache Software Foundation and was
00052  * originally based on software copyright (c) 1999, International
00053  * Business Machines, Inc., http://www.ibm.com.  For more
00054  * information on the Apache Software Foundation, please see
00055  * <http://www.apache.org/>.
00056  */
00057 #if !defined(XALANTRANSFORMER_HEADER_GUARD)
00058 #define XALANTRANSFORMER_HEADER_GUARD
00059 
00060 
00061 
00062 // Base include file.  Must be first.
00063 #include <xalanc/XalanTransformer/XalanTransformerDefinitions.hpp>
00064 
00065 
00066 
00067 #include <cassert>
00068 #include <vector>
00069 
00070 #if defined(XALAN_CLASSIC_IOSTREAMS)
00071 class ostream;
00072 #else
00073 #include <iosfwd>
00074 #endif
00075 
00076 
00077 
00078 #include <xalanc/XPath/XalanQNameByValue.hpp>
00079 
00080 
00081 
00082 #include <xalanc/XSLT/XSLTInputSource.hpp>
00083 #include <xalanc/XSLT/XSLTResultTarget.hpp>
00084 
00085 
00086 
00087 XALAN_DECLARE_XERCES_CLASS(EntityResolver)
00088 XALAN_DECLARE_XERCES_CLASS(ErrorHandler)
00089 
00090 
00091 
00092 XALAN_CPP_NAMESPACE_BEGIN
00093 
00094 
00095 
00096 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver   EntityResolverType;
00097 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler     ErrorHandlerType;
00098 
00099 
00100 
00101 class Function;
00102 class StylesheetExecutionContextDefault;
00103 class ProblemListener;
00104 class TraceListener;
00105 class XSLTInit;
00106 class XalanDocumentBuilder;
00107 class XalanCompiledStylesheet;
00108 class XalanParsedSource;
00109 class XalanTransformerOutputStream;
00110 
00111 
00112 
00119 class XALAN_TRANSFORMER_EXPORT XalanTransformer
00120 {
00121 public:
00122     
00123 #if defined(XALAN_NO_STD_NAMESPACE)
00124     typedef ostream         StreamType;
00125 #else
00126     typedef std::ostream    StreamType;
00127 #endif
00128 
00129     XalanTransformer();
00130 
00131     virtual
00132     ~XalanTransformer();
00133 
00142     static void
00143     initialize();
00144 
00157     static void
00158     terminate();
00159 
00178     static void
00179     ICUCleanUp();
00180 
00181 
00191     int
00192     transform(
00193             const XalanParsedSource&    theParsedXML, 
00194             const XSLTInputSource&      theStylesheetSource,
00195             const XSLTResultTarget&     theResultTarget)
00196     {
00197         return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget);
00198     }
00199 
00209     int
00210     transform(
00211             const XalanParsedSource&        theParsedXML,
00212             const XalanCompiledStylesheet*  theCompiledStylesheet,
00213             const XSLTResultTarget&         theResultTarget)
00214     {
00215         assert(theCompiledStylesheet != 0);
00216 
00217         return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget);
00218     }
00219 
00229     int
00230     transform(
00231             const XalanParsedSource&    theParsedXML,                
00232             const XSLTResultTarget&     theResultTarget)
00233     {
00234         assert(s_emptyInputSource != 0);
00235 
00236         return transform(theParsedXML, *s_emptyInputSource, theResultTarget);
00237     }
00238 
00250     int
00251     transform(
00252             const XSLTInputSource&      theInputSource,
00253             const XSLTInputSource&      theStylesheetSource,
00254             const XSLTResultTarget&     theResultTarget);
00255 
00266     int
00267     transform(
00268             const XSLTInputSource&      theInputSource,
00269             const XSLTResultTarget&     theResultTarget)
00270     {
00271         assert(s_emptyInputSource != 0);
00272 
00273         return transform(
00274                         theInputSource, 
00275                         *s_emptyInputSource,
00276                         theResultTarget);
00277     }
00278 
00297     int
00298     transform(
00299             const XSLTInputSource&      theInputSource, 
00300             const XSLTInputSource&      theStylesheetSource,
00301             void*                       theOutputHandle, 
00302             XalanOutputHandlerType      theOutputHandler,
00303             XalanFlushHandlerType       theFlushHandler = 0);
00304     
00316     int
00317     transform(
00318             const XSLTInputSource&          theInputSource, 
00319             const XalanCompiledStylesheet*  theCompiledStylesheet,
00320             const XSLTResultTarget&         theResultTarget);
00321  
00340     int
00341     transform(
00342             const XalanParsedSource&        theParsedSource,
00343             const XalanCompiledStylesheet*  theCompiledStylesheet,
00344             void*                           theOutputHandle,
00345             XalanOutputHandlerType          theOutputHandler,
00346             XalanFlushHandlerType           theFlushHandler = 0);
00347 
00365     int
00366     transform(
00367             const XSLTInputSource&      theInputSource,
00368             void*                       theOutputHandle,
00369             XalanOutputHandlerType      theOutputHandler,
00370             XalanFlushHandlerType       theFlushHandler = 0);
00371 
00384     int
00385     compileStylesheet(
00386             const XSLTInputSource&              theStylesheetSource,
00387             const XalanCompiledStylesheet*&     theCompiledStylesheet);
00388 
00396     int
00397     destroyStylesheet(const XalanCompiledStylesheet*    theStylesheet);
00398 
00412     int
00413     parseSource(
00414             const XSLTInputSource&      theInputSource,
00415             const XalanParsedSource*&   theParsedSource,
00416             bool                        useXercesDOM = false);
00417 
00424     int
00425     destroyParsedSource(const XalanParsedSource*    theParsedSource);
00426 
00436     XalanDocumentBuilder*
00437     createDocumentBuilder();
00438 
00446     void
00447     destroyDocumentBuilder(XalanDocumentBuilder*    theDocumentBuilder);
00448 
00456     void
00457     installExternalFunction(
00458             const XalanDOMString&   theNamespace,
00459             const XalanDOMString&   functionName,
00460             const Function&         function);
00461 
00469     static void
00470     installExternalFunctionGlobal(
00471             const XalanDOMString&   theNamespace,
00472             const XalanDOMString&   functionName,
00473             const Function&         function);
00474 
00481     void
00482     uninstallExternalFunction(
00483             const XalanDOMString&   theNamespace,
00484             const XalanDOMString&   functionName);
00485 
00492     static void
00493     uninstallExternalFunctionGlobal(
00494             const XalanDOMString&   theNamespace,
00495             const XalanDOMString&   functionName);
00496 
00504     void
00505     setStylesheetParam(
00506             const XalanDOMString&   key,
00507             const XalanDOMString&   expression);
00508 
00516     void
00517     setStylesheetParam(
00518             const char*     key,
00519             const char*     expression);
00520 
00528     void
00529     addTraceListener(TraceListener*     theTraceListener)
00530     {
00531         m_traceListeners.push_back(theTraceListener);
00532     }
00533 
00540     bool
00541     removeTraceListener(TraceListener*  theTraceListener);
00542 
00546     void
00547     removeTraceListeners()
00548     {
00549         m_traceListeners.clear();
00550     }
00551 
00558     bool
00559     getUseValidation() const
00560     {
00561         return m_useValidation;
00562     }
00563 
00570     void
00571     setUseValidation(bool   fValue)
00572     {
00573         m_useValidation = fValue;
00574     }
00575 
00581     EntityResolverType*
00582     getEntityResolver() const
00583     {
00584         return m_entityResolver;
00585     }
00586 
00596     void
00597     setEntityResolver(EntityResolverType*   theResolver)
00598     {
00599         m_entityResolver = theResolver;
00600     }
00601 
00607     ErrorHandlerType*
00608     getErrorHandler() const
00609     {
00610         return m_errorHandler;
00611     }
00612 
00618     void
00619     setErrorHandler(ErrorHandlerType*   theErrorHandler)
00620     {
00621         m_errorHandler = theErrorHandler;
00622     }
00623 
00630     const XalanDOMChar*
00631     getExternalSchemaLocation() const
00632     {
00633         return m_externalSchemaLocation.size() == 0 ? 0 : m_externalSchemaLocation.c_str();
00634     }
00635 
00642     void
00643     setExternalSchemaLocation(const XalanDOMChar*   location)
00644     {
00645         assert(location != 0);
00646 
00647         m_externalSchemaLocation = location;
00648     }
00649 
00656     const XalanDOMChar*
00657     getExternalNoNamespaceSchemaLocation() const
00658     {
00659         return m_externalNoNamespaceSchemaLocation.size() == 0 ? 0 : m_externalNoNamespaceSchemaLocation.c_str();
00660     }
00661 
00668     void
00669     setExternalNoNamespaceSchemaLocation(const XalanDOMChar*    location)
00670     {
00671         assert(location != 0);
00672 
00673         m_externalNoNamespaceSchemaLocation = location;
00674     }
00675 
00681     ProblemListener*
00682     getProblemListener() const
00683     {
00684         return  m_problemListener;
00685     }
00686 
00692     void
00693     setProblemListener(ProblemListener*     theProblemListener)
00694     {
00695         m_problemListener = theProblemListener;
00696     }
00697 
00704     const char*
00705     getLastError() const
00706     {
00707         assert(m_errorMessage.size() > 0);
00708 
00709         return &m_errorMessage[0]; 
00710     }
00711 
00718     const XalanDOMString&
00719     getOutputEncoding() const
00720     {
00721         return m_outputEncoding;
00722     }
00723 
00732     void
00733     setOutputEncoding(const XalanDOMString&     theEncoding)
00734     {
00735         m_outputEncoding = theEncoding;
00736     }
00737 
00743     int
00744     getIndent() const;
00745 
00751     void
00752     setIndent(int   indentAmount);
00753 
00757     enum eEscapeURLs
00758     {
00759         eEscapeURLsDefault,     // Use the value in the stylesheet
00760         eEscapeURLsNo,          // Don't escape URLs
00761         eEscapeURLsYes          // Escape URLs
00762     };
00763 
00771     eEscapeURLs
00772     getEscapeURLs() const;
00773 
00781     void
00782     setEscapeURLs(eEscapeURLs   value);
00783 
00788     enum eOmitMETATag
00789     {
00790         eOmitMETATagDefault,    // Use the value in the stylesheet
00791         eOmitMETATagNo,         // Don't omit the META tag
00792         eOmitMETATagYes         // Omit the META tag
00793     };
00794 
00802     eOmitMETATag
00803     getOmitMETATag() const;
00804 
00812     void
00813     setOmitMETATag(eOmitMETATag     value);
00814 
00823     void
00824     setWarningStream(StreamType*    theStream)
00825     {
00826         m_warningStream = theStream;
00827     }
00828 
00834     StreamType*
00835     getWarningStream() const
00836     {
00837         return m_warningStream;
00838     }
00839 
00840 #if defined(XALAN_NO_STD_NAMESPACE)
00841     typedef vector<const XalanCompiledStylesheet*>      CompiledStylesheetPtrVectorType;
00842     typedef vector<const XalanParsedSource*>            ParsedSourcePtrVectorType;
00843     typedef pair<XalanDOMString, XalanDOMString>        ParamPairType;
00844     typedef vector<ParamPairType>                       ParamPairVectorType;
00845     typedef pair<XalanQNameByValue, Function*>          FunctionPairType;
00846     typedef vector<FunctionPairType>                    FunctionParamPairVectorType;
00847     typedef vector<TraceListener*>                      TraceListenerVectorType;
00848 #else
00849     typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType;
00850     typedef std::vector<const XalanParsedSource*>       ParsedSourcePtrVectorType;
00851     typedef std::pair<XalanDOMString, XalanDOMString>   ParamPairType;
00852     typedef std::vector<ParamPairType>                  ParamPairVectorType;
00853     typedef std::pair<XalanQNameByValue, Function*>     FunctionPairType;
00854     typedef std::vector<FunctionPairType>               FunctionParamPairVectorType;
00855     typedef std::vector<TraceListener*>                 TraceListenerVectorType;
00856 #endif
00857 
00858     class EnsureDestroyParsedSource
00859     {
00860     public:
00861 
00862         EnsureDestroyParsedSource(
00863                 XalanTransformer&           theTransformer,
00864                 const XalanParsedSource*    theParsedSource) :
00865             m_transformer(theTransformer),
00866             m_parsedSource(theParsedSource)
00867         {
00868         }
00869 
00870         ~EnsureDestroyParsedSource()
00871         {
00872             m_transformer.destroyParsedSource(m_parsedSource);
00873         }
00874 
00875     private:
00876 
00877         XalanTransformer&               m_transformer;
00878 
00879         const XalanParsedSource* const  m_parsedSource;
00880     };
00881 
00882     struct EnsureDestroyCompiledStylesheet
00883     {
00884         EnsureDestroyCompiledStylesheet(
00885                 XalanTransformer&               theTransformer,
00886                 const XalanCompiledStylesheet*  theCompiledStylesheet) :
00887             m_transformer(theTransformer),
00888             m_compiledStylesheet(theCompiledStylesheet)
00889         {
00890         }
00891 
00892         ~EnsureDestroyCompiledStylesheet()
00893         {
00894             m_transformer.destroyStylesheet(m_compiledStylesheet);
00895         }
00896 
00897     private:
00898 
00899         XalanTransformer&                       m_transformer;
00900 
00901         const XalanCompiledStylesheet* const    m_compiledStylesheet;
00902     };
00903 
00904     struct EnsureDestroyDocumentBuilder
00905     {
00906         EnsureDestroyDocumentBuilder(
00907                 XalanTransformer&       theTransformer,
00908                 XalanDocumentBuilder*   theDocumentBuilder) :
00909             m_transformer(theTransformer),
00910             m_documentBuilder(theDocumentBuilder)
00911         {
00912         }
00913 
00914         ~EnsureDestroyDocumentBuilder()
00915         {
00916             m_transformer.destroyDocumentBuilder(m_documentBuilder);
00917         }
00918 
00919     private:
00920 
00921         XalanTransformer&           m_transformer;
00922 
00923         XalanDocumentBuilder* const m_documentBuilder;
00924     };
00925 
00926 protected:
00927 
00928 private:
00929 
00930     void
00931     reset();
00932 
00933     class EnsureReset
00934     {
00935     public:
00936 
00937         EnsureReset(XalanTransformer&   theTransformer) :
00938             m_transformer(theTransformer)
00939         {
00940         }
00941 
00942         ~EnsureReset();
00943 
00944     private:
00945 
00946         XalanTransformer&   m_transformer;
00947     };
00948 
00949     friend class EnsureReset;
00950 
00951     int
00952     doTransform(
00953             const XalanParsedSource&        theParsedXML, 
00954             const XalanCompiledStylesheet*  theCompiledStylesheet,
00955             const XSLTInputSource*          theStylesheetSource,
00956             const XSLTResultTarget&         theResultTarget);
00957 
00958 
00959     // Data members...
00960     CompiledStylesheetPtrVectorType         m_compiledStylesheets;
00961 
00962     ParsedSourcePtrVectorType               m_parsedSources;
00963 
00964     ParamPairVectorType                     m_paramPairs;
00965 
00966     FunctionParamPairVectorType             m_functionPairs;
00967 
00968     TraceListenerVectorType                 m_traceListeners;
00969 
00970     CharVectorType                          m_errorMessage;
00971 
00972     bool                                    m_useValidation;
00973 
00974     EntityResolverType*                     m_entityResolver;
00975 
00976     ErrorHandlerType*                       m_errorHandler;
00977 
00978     XalanDOMString                          m_externalSchemaLocation;
00979 
00980     XalanDOMString                          m_externalNoNamespaceSchemaLocation;
00981 
00982     ProblemListener*                        m_problemListener;
00983 
00984     StreamType*                             m_warningStream;
00985 
00986     XalanDOMString                          m_outputEncoding;
00987 
00988     // This should always be the latest data member!!!
00989     StylesheetExecutionContextDefault*      m_stylesheetExecutionContext;
00990 
00991     static const XSLTInputSource*           s_emptyInputSource;
00992 
00993     static const XSLTInit*                  s_xsltInit;
00994 };
00995 
00996 
00997 
00998 XALAN_CPP_NAMESPACE_END
00999 
01000 
01001 
01002 #endif  // XALANTRANSFORMER_HEADER_GUARD

Interpreting class diagrams

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

Xalan-C++ XSLT Processor Version 1.6
Copyright © 2000, 2001, 2002, 2003 The Apache Software Foundation. All Rights Reserved.