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 #include <vector> 00028 00029 #if defined(XALAN_CLASSIC_IOSTREAMS) 00030 class ostream; 00031 #else 00032 #include <iosfwd> 00033 #endif 00034 00035 00036 00037 #include <xalanc/XPath/XalanQNameByValue.hpp> 00038 00039 00040 00041 #include <xalanc/XSLT/XSLTInputSource.hpp> 00042 #include <xalanc/XSLT/XSLTResultTarget.hpp> 00043 00044 00045 00046 XALAN_DECLARE_XERCES_CLASS(EntityResolver) 00047 XALAN_DECLARE_XERCES_CLASS(ErrorHandler) 00048 00049 00050 00051 XALAN_CPP_NAMESPACE_BEGIN 00052 00053 00054 00055 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType; 00056 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType; 00057 00058 00059 00060 class Function; 00061 class StylesheetExecutionContextDefault; 00062 class ProblemListener; 00063 class TraceListener; 00064 class XSLTInit; 00065 class XalanDocumentBuilder; 00066 class XalanCompiledStylesheet; 00067 class XalanParsedSource; 00068 class XalanTransformerOutputStream; 00069 00070 00071 00078 class XALAN_TRANSFORMER_EXPORT XalanTransformer 00079 { 00080 public: 00081 00082 #if defined(XALAN_NO_STD_NAMESPACE) 00083 typedef ostream StreamType; 00084 #else 00085 typedef std::ostream StreamType; 00086 #endif 00087 00088 XalanTransformer(); 00089 00090 virtual 00091 ~XalanTransformer(); 00092 00101 static void 00102 initialize(); 00103 00116 static void 00117 terminate(); 00118 00137 static void 00138 ICUCleanUp(); 00139 00140 00150 int 00151 transform( 00152 const XalanParsedSource& theParsedXML, 00153 const XSLTInputSource& theStylesheetSource, 00154 const XSLTResultTarget& theResultTarget) 00155 { 00156 return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget); 00157 } 00158 00168 int 00169 transform( 00170 const XalanParsedSource& theParsedXML, 00171 const XalanCompiledStylesheet* theCompiledStylesheet, 00172 const XSLTResultTarget& theResultTarget) 00173 { 00174 assert(theCompiledStylesheet != 0); 00175 00176 return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget); 00177 } 00178 00188 int 00189 transform( 00190 const XalanParsedSource& theParsedXML, 00191 const XSLTResultTarget& theResultTarget) 00192 { 00193 assert(s_emptyInputSource != 0); 00194 00195 return transform(theParsedXML, *s_emptyInputSource, theResultTarget); 00196 } 00197 00209 int 00210 transform( 00211 const XSLTInputSource& theInputSource, 00212 const XSLTInputSource& theStylesheetSource, 00213 const XSLTResultTarget& theResultTarget); 00214 00225 int 00226 transform( 00227 const XSLTInputSource& theInputSource, 00228 const XSLTResultTarget& theResultTarget) 00229 { 00230 assert(s_emptyInputSource != 0); 00231 00232 return transform( 00233 theInputSource, 00234 *s_emptyInputSource, 00235 theResultTarget); 00236 } 00237 00256 int 00257 transform( 00258 const XSLTInputSource& theInputSource, 00259 const XSLTInputSource& theStylesheetSource, 00260 void* theOutputHandle, 00261 XalanOutputHandlerType theOutputHandler, 00262 XalanFlushHandlerType theFlushHandler = 0); 00263 00275 int 00276 transform( 00277 const XSLTInputSource& theInputSource, 00278 const XalanCompiledStylesheet* theCompiledStylesheet, 00279 const XSLTResultTarget& theResultTarget); 00280 00299 int 00300 transform( 00301 const XalanParsedSource& theParsedSource, 00302 const XalanCompiledStylesheet* theCompiledStylesheet, 00303 void* theOutputHandle, 00304 XalanOutputHandlerType theOutputHandler, 00305 XalanFlushHandlerType theFlushHandler = 0); 00306 00324 int 00325 transform( 00326 const XSLTInputSource& theInputSource, 00327 void* theOutputHandle, 00328 XalanOutputHandlerType theOutputHandler, 00329 XalanFlushHandlerType theFlushHandler = 0); 00330 00343 int 00344 compileStylesheet( 00345 const XSLTInputSource& theStylesheetSource, 00346 const XalanCompiledStylesheet*& theCompiledStylesheet); 00347 00355 int 00356 destroyStylesheet(const XalanCompiledStylesheet* theStylesheet); 00357 00371 int 00372 parseSource( 00373 const XSLTInputSource& theInputSource, 00374 const XalanParsedSource*& theParsedSource, 00375 bool useXercesDOM = false); 00376 00383 int 00384 destroyParsedSource(const XalanParsedSource* theParsedSource); 00385 00396 XalanDocumentBuilder* 00397 createDocumentBuilder(const XalanDOMString& theURI = XalanDOMString()); 00398 00406 void 00407 destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder); 00408 00416 void 00417 installExternalFunction( 00418 const XalanDOMString& theNamespace, 00419 const XalanDOMString& functionName, 00420 const Function& function); 00421 00429 static void 00430 installExternalFunctionGlobal( 00431 const XalanDOMString& theNamespace, 00432 const XalanDOMString& functionName, 00433 const Function& function); 00434 00441 void 00442 uninstallExternalFunction( 00443 const XalanDOMString& theNamespace, 00444 const XalanDOMString& functionName); 00445 00452 static void 00453 uninstallExternalFunctionGlobal( 00454 const XalanDOMString& theNamespace, 00455 const XalanDOMString& functionName); 00456 00464 void 00465 setStylesheetParam( 00466 const XalanDOMString& key, 00467 const XalanDOMString& expression); 00468 00476 void 00477 setStylesheetParam( 00478 const char* key, 00479 const char* expression); 00480 00488 void 00489 addTraceListener(TraceListener* theTraceListener) 00490 { 00491 m_traceListeners.push_back(theTraceListener); 00492 } 00493 00500 bool 00501 removeTraceListener(TraceListener* theTraceListener); 00502 00506 void 00507 removeTraceListeners() 00508 { 00509 m_traceListeners.clear(); 00510 } 00511 00518 bool 00519 getUseValidation() const 00520 { 00521 return m_useValidation; 00522 } 00523 00530 void 00531 setUseValidation(bool fValue) 00532 { 00533 m_useValidation = fValue; 00534 } 00535 00541 EntityResolverType* 00542 getEntityResolver() const 00543 { 00544 return m_entityResolver; 00545 } 00546 00556 void 00557 setEntityResolver(EntityResolverType* theResolver) 00558 { 00559 m_entityResolver = theResolver; 00560 } 00561 00567 ErrorHandlerType* 00568 getErrorHandler() const 00569 { 00570 return m_errorHandler; 00571 } 00572 00578 void 00579 setErrorHandler(ErrorHandlerType* theErrorHandler) 00580 { 00581 m_errorHandler = theErrorHandler; 00582 } 00583 00590 const XalanDOMChar* 00591 getExternalSchemaLocation() const 00592 { 00593 return m_externalSchemaLocation.empty() == true ? 0 : m_externalSchemaLocation.c_str(); 00594 } 00595 00602 void 00603 setExternalSchemaLocation(const XalanDOMChar* location) 00604 { 00605 assert(location != 0); 00606 00607 m_externalSchemaLocation = location; 00608 } 00609 00616 const XalanDOMChar* 00617 getExternalNoNamespaceSchemaLocation() const 00618 { 00619 return m_externalNoNamespaceSchemaLocation.empty() == true ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); 00620 } 00621 00628 void 00629 setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) 00630 { 00631 assert(location != 0); 00632 00633 m_externalNoNamespaceSchemaLocation = location; 00634 } 00635 00641 ProblemListener* 00642 getProblemListener() const 00643 { 00644 return m_problemListener; 00645 } 00646 00652 void 00653 setProblemListener(ProblemListener* theProblemListener) 00654 { 00655 m_problemListener = theProblemListener; 00656 } 00657 00664 const char* 00665 getLastError() const 00666 { 00667 assert(m_errorMessage.empty() == false); 00668 00669 return &m_errorMessage[0]; 00670 } 00671 00678 const XalanDOMString& 00679 getOutputEncoding() const 00680 { 00681 return m_outputEncoding; 00682 } 00683 00692 void 00693 setOutputEncoding(const XalanDOMString& theEncoding) 00694 { 00695 m_outputEncoding = theEncoding; 00696 } 00697 00703 int 00704 getIndent() const; 00705 00711 void 00712 setIndent(int indentAmount); 00713 00717 enum eEscapeURLs 00718 { 00719 eEscapeURLsDefault, // Use the value in the stylesheet 00720 eEscapeURLsNo, // Don't escape URLs 00721 eEscapeURLsYes // Escape URLs 00722 }; 00723 00731 eEscapeURLs 00732 getEscapeURLs() const; 00733 00741 void 00742 setEscapeURLs(eEscapeURLs value); 00743 00748 enum eOmitMETATag 00749 { 00750 eOmitMETATagDefault, // Use the value in the stylesheet 00751 eOmitMETATagNo, // Don't omit the META tag 00752 eOmitMETATagYes // Omit the META tag 00753 }; 00754 00762 eOmitMETATag 00763 getOmitMETATag() const; 00764 00772 void 00773 setOmitMETATag(eOmitMETATag value); 00774 00783 void 00784 setWarningStream(StreamType* theStream) 00785 { 00786 m_warningStream = theStream; 00787 } 00788 00794 StreamType* 00795 getWarningStream() const 00796 { 00797 return m_warningStream; 00798 } 00799 00800 #if defined(XALAN_NO_STD_NAMESPACE) 00801 typedef vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00802 typedef vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00803 typedef pair<XalanDOMString, XalanDOMString> ParamPairType; 00804 typedef vector<ParamPairType> ParamPairVectorType; 00805 typedef pair<XalanQNameByValue, Function*> FunctionPairType; 00806 typedef vector<FunctionPairType> FunctionParamPairVectorType; 00807 typedef vector<TraceListener*> TraceListenerVectorType; 00808 #else 00809 typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00810 typedef std::vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00811 typedef std::pair<XalanDOMString, XalanDOMString> ParamPairType; 00812 typedef std::vector<ParamPairType> ParamPairVectorType; 00813 typedef std::pair<XalanQNameByValue, Function*> FunctionPairType; 00814 typedef std::vector<FunctionPairType> FunctionParamPairVectorType; 00815 typedef std::vector<TraceListener*> TraceListenerVectorType; 00816 #endif 00817 00818 class EnsureDestroyParsedSource 00819 { 00820 public: 00821 00822 EnsureDestroyParsedSource( 00823 XalanTransformer& theTransformer, 00824 const XalanParsedSource* theParsedSource) : 00825 m_transformer(theTransformer), 00826 m_parsedSource(theParsedSource) 00827 { 00828 } 00829 00830 ~EnsureDestroyParsedSource() 00831 { 00832 m_transformer.destroyParsedSource(m_parsedSource); 00833 } 00834 00835 private: 00836 00837 XalanTransformer& m_transformer; 00838 00839 const XalanParsedSource* const m_parsedSource; 00840 }; 00841 00842 struct EnsureDestroyCompiledStylesheet 00843 { 00844 EnsureDestroyCompiledStylesheet( 00845 XalanTransformer& theTransformer, 00846 const XalanCompiledStylesheet* theCompiledStylesheet) : 00847 m_transformer(theTransformer), 00848 m_compiledStylesheet(theCompiledStylesheet) 00849 { 00850 } 00851 00852 ~EnsureDestroyCompiledStylesheet() 00853 { 00854 m_transformer.destroyStylesheet(m_compiledStylesheet); 00855 } 00856 00857 private: 00858 00859 XalanTransformer& m_transformer; 00860 00861 const XalanCompiledStylesheet* const m_compiledStylesheet; 00862 }; 00863 00864 struct EnsureDestroyDocumentBuilder 00865 { 00866 EnsureDestroyDocumentBuilder( 00867 XalanTransformer& theTransformer, 00868 XalanDocumentBuilder* theDocumentBuilder) : 00869 m_transformer(theTransformer), 00870 m_documentBuilder(theDocumentBuilder) 00871 { 00872 } 00873 00874 ~EnsureDestroyDocumentBuilder() 00875 { 00876 m_transformer.destroyDocumentBuilder(m_documentBuilder); 00877 } 00878 00879 private: 00880 00881 XalanTransformer& m_transformer; 00882 00883 XalanDocumentBuilder* const m_documentBuilder; 00884 }; 00885 00886 protected: 00887 00888 private: 00889 00890 void 00891 reset(); 00892 00893 class EnsureReset 00894 { 00895 public: 00896 00897 EnsureReset(XalanTransformer& theTransformer) : 00898 m_transformer(theTransformer) 00899 { 00900 } 00901 00902 ~EnsureReset(); 00903 00904 private: 00905 00906 XalanTransformer& m_transformer; 00907 }; 00908 00909 friend class EnsureReset; 00910 00911 int 00912 doTransform( 00913 const XalanParsedSource& theParsedXML, 00914 const XalanCompiledStylesheet* theCompiledStylesheet, 00915 const XSLTInputSource* theStylesheetSource, 00916 const XSLTResultTarget& theResultTarget); 00917 00918 00919 // Data members... 00920 CompiledStylesheetPtrVectorType m_compiledStylesheets; 00921 00922 ParsedSourcePtrVectorType m_parsedSources; 00923 00924 ParamPairVectorType m_paramPairs; 00925 00926 FunctionParamPairVectorType m_functionPairs; 00927 00928 TraceListenerVectorType m_traceListeners; 00929 00930 CharVectorType m_errorMessage; 00931 00932 bool m_useValidation; 00933 00934 EntityResolverType* m_entityResolver; 00935 00936 ErrorHandlerType* m_errorHandler; 00937 00938 XalanDOMString m_externalSchemaLocation; 00939 00940 XalanDOMString m_externalNoNamespaceSchemaLocation; 00941 00942 ProblemListener* m_problemListener; 00943 00944 StreamType* m_warningStream; 00945 00946 XalanDOMString m_outputEncoding; 00947 00948 // This should always be the latest data member!!! 00949 StylesheetExecutionContextDefault* m_stylesheetExecutionContext; 00950 00951 static const XSLTInputSource* s_emptyInputSource; 00952 00953 static const XSLTInit* s_xsltInit; 00954 }; 00955 00956 00957 00958 XALAN_CPP_NAMESPACE_END 00959 00960 00961 00962 #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.8 |
|