00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999-2004 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 00437 XalanDocumentBuilder* 00438 createDocumentBuilder(const XalanDOMString& theURI = XalanDOMString()); 00439 00447 void 00448 destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder); 00449 00457 void 00458 installExternalFunction( 00459 const XalanDOMString& theNamespace, 00460 const XalanDOMString& functionName, 00461 const Function& function); 00462 00470 static void 00471 installExternalFunctionGlobal( 00472 const XalanDOMString& theNamespace, 00473 const XalanDOMString& functionName, 00474 const Function& function); 00475 00482 void 00483 uninstallExternalFunction( 00484 const XalanDOMString& theNamespace, 00485 const XalanDOMString& functionName); 00486 00493 static void 00494 uninstallExternalFunctionGlobal( 00495 const XalanDOMString& theNamespace, 00496 const XalanDOMString& functionName); 00497 00505 void 00506 setStylesheetParam( 00507 const XalanDOMString& key, 00508 const XalanDOMString& expression); 00509 00517 void 00518 setStylesheetParam( 00519 const char* key, 00520 const char* expression); 00521 00529 void 00530 addTraceListener(TraceListener* theTraceListener) 00531 { 00532 m_traceListeners.push_back(theTraceListener); 00533 } 00534 00541 bool 00542 removeTraceListener(TraceListener* theTraceListener); 00543 00547 void 00548 removeTraceListeners() 00549 { 00550 m_traceListeners.clear(); 00551 } 00552 00559 bool 00560 getUseValidation() const 00561 { 00562 return m_useValidation; 00563 } 00564 00571 void 00572 setUseValidation(bool fValue) 00573 { 00574 m_useValidation = fValue; 00575 } 00576 00582 EntityResolverType* 00583 getEntityResolver() const 00584 { 00585 return m_entityResolver; 00586 } 00587 00597 void 00598 setEntityResolver(EntityResolverType* theResolver) 00599 { 00600 m_entityResolver = theResolver; 00601 } 00602 00608 ErrorHandlerType* 00609 getErrorHandler() const 00610 { 00611 return m_errorHandler; 00612 } 00613 00619 void 00620 setErrorHandler(ErrorHandlerType* theErrorHandler) 00621 { 00622 m_errorHandler = theErrorHandler; 00623 } 00624 00631 const XalanDOMChar* 00632 getExternalSchemaLocation() const 00633 { 00634 return m_externalSchemaLocation.empty() == true ? 0 : m_externalSchemaLocation.c_str(); 00635 } 00636 00643 void 00644 setExternalSchemaLocation(const XalanDOMChar* location) 00645 { 00646 assert(location != 0); 00647 00648 m_externalSchemaLocation = location; 00649 } 00650 00657 const XalanDOMChar* 00658 getExternalNoNamespaceSchemaLocation() const 00659 { 00660 return m_externalNoNamespaceSchemaLocation.empty() == true ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); 00661 } 00662 00669 void 00670 setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) 00671 { 00672 assert(location != 0); 00673 00674 m_externalNoNamespaceSchemaLocation = location; 00675 } 00676 00682 ProblemListener* 00683 getProblemListener() const 00684 { 00685 return m_problemListener; 00686 } 00687 00693 void 00694 setProblemListener(ProblemListener* theProblemListener) 00695 { 00696 m_problemListener = theProblemListener; 00697 } 00698 00705 const char* 00706 getLastError() const 00707 { 00708 assert(m_errorMessage.empty() == false); 00709 00710 return &m_errorMessage[0]; 00711 } 00712 00719 const XalanDOMString& 00720 getOutputEncoding() const 00721 { 00722 return m_outputEncoding; 00723 } 00724 00733 void 00734 setOutputEncoding(const XalanDOMString& theEncoding) 00735 { 00736 m_outputEncoding = theEncoding; 00737 } 00738 00744 int 00745 getIndent() const; 00746 00752 void 00753 setIndent(int indentAmount); 00754 00758 enum eEscapeURLs 00759 { 00760 eEscapeURLsDefault, // Use the value in the stylesheet 00761 eEscapeURLsNo, // Don't escape URLs 00762 eEscapeURLsYes // Escape URLs 00763 }; 00764 00772 eEscapeURLs 00773 getEscapeURLs() const; 00774 00782 void 00783 setEscapeURLs(eEscapeURLs value); 00784 00789 enum eOmitMETATag 00790 { 00791 eOmitMETATagDefault, // Use the value in the stylesheet 00792 eOmitMETATagNo, // Don't omit the META tag 00793 eOmitMETATagYes // Omit the META tag 00794 }; 00795 00803 eOmitMETATag 00804 getOmitMETATag() const; 00805 00813 void 00814 setOmitMETATag(eOmitMETATag value); 00815 00824 void 00825 setWarningStream(StreamType* theStream) 00826 { 00827 m_warningStream = theStream; 00828 } 00829 00835 StreamType* 00836 getWarningStream() const 00837 { 00838 return m_warningStream; 00839 } 00840 00841 #if defined(XALAN_NO_STD_NAMESPACE) 00842 typedef vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00843 typedef vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00844 typedef pair<XalanDOMString, XalanDOMString> ParamPairType; 00845 typedef vector<ParamPairType> ParamPairVectorType; 00846 typedef pair<XalanQNameByValue, Function*> FunctionPairType; 00847 typedef vector<FunctionPairType> FunctionParamPairVectorType; 00848 typedef vector<TraceListener*> TraceListenerVectorType; 00849 #else 00850 typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00851 typedef std::vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00852 typedef std::pair<XalanDOMString, XalanDOMString> ParamPairType; 00853 typedef std::vector<ParamPairType> ParamPairVectorType; 00854 typedef std::pair<XalanQNameByValue, Function*> FunctionPairType; 00855 typedef std::vector<FunctionPairType> FunctionParamPairVectorType; 00856 typedef std::vector<TraceListener*> TraceListenerVectorType; 00857 #endif 00858 00859 class EnsureDestroyParsedSource 00860 { 00861 public: 00862 00863 EnsureDestroyParsedSource( 00864 XalanTransformer& theTransformer, 00865 const XalanParsedSource* theParsedSource) : 00866 m_transformer(theTransformer), 00867 m_parsedSource(theParsedSource) 00868 { 00869 } 00870 00871 ~EnsureDestroyParsedSource() 00872 { 00873 m_transformer.destroyParsedSource(m_parsedSource); 00874 } 00875 00876 private: 00877 00878 XalanTransformer& m_transformer; 00879 00880 const XalanParsedSource* const m_parsedSource; 00881 }; 00882 00883 struct EnsureDestroyCompiledStylesheet 00884 { 00885 EnsureDestroyCompiledStylesheet( 00886 XalanTransformer& theTransformer, 00887 const XalanCompiledStylesheet* theCompiledStylesheet) : 00888 m_transformer(theTransformer), 00889 m_compiledStylesheet(theCompiledStylesheet) 00890 { 00891 } 00892 00893 ~EnsureDestroyCompiledStylesheet() 00894 { 00895 m_transformer.destroyStylesheet(m_compiledStylesheet); 00896 } 00897 00898 private: 00899 00900 XalanTransformer& m_transformer; 00901 00902 const XalanCompiledStylesheet* const m_compiledStylesheet; 00903 }; 00904 00905 struct EnsureDestroyDocumentBuilder 00906 { 00907 EnsureDestroyDocumentBuilder( 00908 XalanTransformer& theTransformer, 00909 XalanDocumentBuilder* theDocumentBuilder) : 00910 m_transformer(theTransformer), 00911 m_documentBuilder(theDocumentBuilder) 00912 { 00913 } 00914 00915 ~EnsureDestroyDocumentBuilder() 00916 { 00917 m_transformer.destroyDocumentBuilder(m_documentBuilder); 00918 } 00919 00920 private: 00921 00922 XalanTransformer& m_transformer; 00923 00924 XalanDocumentBuilder* const m_documentBuilder; 00925 }; 00926 00927 protected: 00928 00929 private: 00930 00931 void 00932 reset(); 00933 00934 class EnsureReset 00935 { 00936 public: 00937 00938 EnsureReset(XalanTransformer& theTransformer) : 00939 m_transformer(theTransformer) 00940 { 00941 } 00942 00943 ~EnsureReset(); 00944 00945 private: 00946 00947 XalanTransformer& m_transformer; 00948 }; 00949 00950 friend class EnsureReset; 00951 00952 int 00953 doTransform( 00954 const XalanParsedSource& theParsedXML, 00955 const XalanCompiledStylesheet* theCompiledStylesheet, 00956 const XSLTInputSource* theStylesheetSource, 00957 const XSLTResultTarget& theResultTarget); 00958 00959 00960 // Data members... 00961 CompiledStylesheetPtrVectorType m_compiledStylesheets; 00962 00963 ParsedSourcePtrVectorType m_parsedSources; 00964 00965 ParamPairVectorType m_paramPairs; 00966 00967 FunctionParamPairVectorType m_functionPairs; 00968 00969 TraceListenerVectorType m_traceListeners; 00970 00971 CharVectorType m_errorMessage; 00972 00973 bool m_useValidation; 00974 00975 EntityResolverType* m_entityResolver; 00976 00977 ErrorHandlerType* m_errorHandler; 00978 00979 XalanDOMString m_externalSchemaLocation; 00980 00981 XalanDOMString m_externalNoNamespaceSchemaLocation; 00982 00983 ProblemListener* m_problemListener; 00984 00985 StreamType* m_warningStream; 00986 00987 XalanDOMString m_outputEncoding; 00988 00989 // This should always be the latest data member!!! 00990 StylesheetExecutionContextDefault* m_stylesheetExecutionContext; 00991 00992 static const XSLTInputSource* s_emptyInputSource; 00993 00994 static const XSLTInit* s_xsltInit; 00995 }; 00996 00997 00998 00999 XALAN_CPP_NAMESPACE_END 01000 01001 01002 01003 #endif // XALANTRANSFORMER_HEADER_GUARD
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.7 |
|