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 <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 <XPath/XalanQNameByValue.hpp> 00079 00080 00081 00082 #include <XSLT/XSLTInputSource.hpp> 00083 #include <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 00235 return transform(theParsedXML, s_emptyInputSource, theResultTarget); 00236 } 00237 00249 int 00250 transform( 00251 const XSLTInputSource& theInputSource, 00252 const XSLTInputSource& theStylesheetSource, 00253 const XSLTResultTarget& theResultTarget); 00254 00265 int 00266 transform( 00267 const XSLTInputSource& theInputSource, 00268 const XSLTResultTarget& theResultTarget) 00269 { 00270 return transform( 00271 theInputSource, 00272 s_emptyInputSource, 00273 theResultTarget); 00274 } 00275 00294 int 00295 transform( 00296 const XSLTInputSource& theInputSource, 00297 const XSLTInputSource& theStylesheetSource, 00298 void* theOutputHandle, 00299 XalanOutputHandlerType theOutputHandler, 00300 XalanFlushHandlerType theFlushHandler = 0); 00301 00313 int 00314 transform( 00315 const XSLTInputSource& theInputSource, 00316 const XalanCompiledStylesheet* theCompiledStylesheet, 00317 const XSLTResultTarget& theResultTarget); 00318 00337 int 00338 transform( 00339 const XalanParsedSource& theParsedSource, 00340 const XalanCompiledStylesheet* theCompiledStylesheet, 00341 void* theOutputHandle, 00342 XalanOutputHandlerType theOutputHandler, 00343 XalanFlushHandlerType theFlushHandler = 0); 00344 00362 int 00363 transform( 00364 const XSLTInputSource& theInputSource, 00365 void* theOutputHandle, 00366 XalanOutputHandlerType theOutputHandler, 00367 XalanFlushHandlerType theFlushHandler = 0); 00368 00381 int 00382 compileStylesheet( 00383 const XSLTInputSource& theStylesheetSource, 00384 const XalanCompiledStylesheet*& theCompiledStylesheet); 00385 00393 int 00394 destroyStylesheet(const XalanCompiledStylesheet* theStylesheet); 00395 00409 int 00410 parseSource( 00411 const XSLTInputSource& theInputSource, 00412 const XalanParsedSource*& theParsedSource, 00413 bool useXercesDOM = false); 00414 00421 int 00422 destroyParsedSource(const XalanParsedSource* theParsedSource); 00423 00433 XalanDocumentBuilder* 00434 createDocumentBuilder(); 00435 00443 void 00444 destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder); 00445 00453 void 00454 installExternalFunction( 00455 const XalanDOMString& theNamespace, 00456 const XalanDOMString& functionName, 00457 const Function& function); 00458 00466 static void 00467 installExternalFunctionGlobal( 00468 const XalanDOMString& theNamespace, 00469 const XalanDOMString& functionName, 00470 const Function& function); 00471 00478 void 00479 uninstallExternalFunction( 00480 const XalanDOMString& theNamespace, 00481 const XalanDOMString& functionName); 00482 00489 static void 00490 uninstallExternalFunctionGlobal( 00491 const XalanDOMString& theNamespace, 00492 const XalanDOMString& functionName); 00493 00501 void 00502 setStylesheetParam( 00503 const XalanDOMString& key, 00504 const XalanDOMString& expression); 00505 00513 void 00514 setStylesheetParam( 00515 const char* key, 00516 const char* expression); 00517 00525 void 00526 addTraceListener(TraceListener* theTraceListener) 00527 { 00528 m_traceListeners.push_back(theTraceListener); 00529 } 00530 00537 bool 00538 removeTraceListener(TraceListener* theTraceListener); 00539 00543 void 00544 removeTraceListeners() 00545 { 00546 m_traceListeners.clear(); 00547 } 00548 00555 bool 00556 getUseValidation() const 00557 { 00558 return m_useValidation; 00559 } 00560 00567 void 00568 setUseValidation(bool fValue) 00569 { 00570 m_useValidation = fValue; 00571 } 00572 00578 EntityResolverType* 00579 getEntityResolver() const 00580 { 00581 return m_entityResolver; 00582 } 00583 00593 void 00594 setEntityResolver(EntityResolverType* theResolver) 00595 { 00596 m_entityResolver = theResolver; 00597 } 00598 00604 ErrorHandlerType* 00605 getErrorHandler() const 00606 { 00607 return m_errorHandler; 00608 } 00609 00615 void 00616 setErrorHandler(ErrorHandlerType* theErrorHandler) 00617 { 00618 m_errorHandler = theErrorHandler; 00619 } 00620 00627 const XalanDOMChar* 00628 getExternalSchemaLocation() const 00629 { 00630 return m_externalSchemaLocation.size() == 0 ? 0 : m_externalSchemaLocation.c_str(); 00631 } 00632 00639 void 00640 setExternalSchemaLocation(const XalanDOMChar* location) 00641 { 00642 assert(location != 0); 00643 00644 m_externalSchemaLocation = location; 00645 } 00646 00653 const XalanDOMChar* 00654 getExternalNoNamespaceSchemaLocation() const 00655 { 00656 return m_externalNoNamespaceSchemaLocation.size() == 0 ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); 00657 } 00658 00665 void 00666 setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) 00667 { 00668 assert(location != 0); 00669 00670 m_externalNoNamespaceSchemaLocation = location; 00671 } 00672 00678 ProblemListener* 00679 getProblemListener() const 00680 { 00681 return m_problemListener; 00682 } 00683 00689 void 00690 setProblemListener(ProblemListener* theProblemListener) 00691 { 00692 m_problemListener = theProblemListener; 00693 } 00694 00701 const char* 00702 getLastError() const 00703 { 00704 assert(m_errorMessage.size() > 0); 00705 00706 return &m_errorMessage[0]; 00707 } 00708 00714 int 00715 getIndent() const; 00716 00722 void 00723 setIndent(int indentAmount); 00724 00728 enum eEscapeURLs 00729 { 00730 eEscapeURLsDefault, // Use the value in the stylesheet 00731 eEscapeURLsNo, // Don't escape URLs 00732 eEscapeURLsYes // Escape URLs 00733 }; 00734 00742 eEscapeURLs 00743 getEscapeURLs() const; 00744 00752 void 00753 setEscapeURLs(eEscapeURLs value); 00754 00759 enum eOmitMETATag 00760 { 00761 eOmitMETATagDefault, // Use the value in the stylesheet 00762 eOmitMETATagNo, // Don't omit the META tag 00763 eOmitMETATagYes // Omit the META tag 00764 }; 00765 00773 eOmitMETATag 00774 getOmitMETATag() const; 00775 00783 void 00784 setOmitMETATag(eOmitMETATag value); 00785 00794 void 00795 setWarningStream(StreamType* theStream) 00796 { 00797 m_warningStream = theStream; 00798 } 00799 00805 StreamType* 00806 getWarningStream() const 00807 { 00808 return m_warningStream; 00809 } 00810 00811 #if defined(XALAN_NO_STD_NAMESPACE) 00812 typedef vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00813 typedef vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00814 typedef pair<XalanDOMString, XalanDOMString> ParamPairType; 00815 typedef vector<ParamPairType> ParamPairVectorType; 00816 typedef pair<XalanQNameByValue, Function*> FunctionPairType; 00817 typedef vector<FunctionPairType> FunctionParamPairVectorType; 00818 typedef vector<TraceListener*> TraceListenerVectorType; 00819 #else 00820 typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00821 typedef std::vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00822 typedef std::pair<XalanDOMString, XalanDOMString> ParamPairType; 00823 typedef std::vector<ParamPairType> ParamPairVectorType; 00824 typedef std::pair<XalanQNameByValue, Function*> FunctionPairType; 00825 typedef std::vector<FunctionPairType> FunctionParamPairVectorType; 00826 typedef std::vector<TraceListener*> TraceListenerVectorType; 00827 #endif 00828 00829 class EnsureDestroyParsedSource 00830 { 00831 public: 00832 00833 EnsureDestroyParsedSource( 00834 XalanTransformer& theTransformer, 00835 const XalanParsedSource* theParsedSource) : 00836 m_transformer(theTransformer), 00837 m_parsedSource(theParsedSource) 00838 { 00839 } 00840 00841 ~EnsureDestroyParsedSource() 00842 { 00843 m_transformer.destroyParsedSource(m_parsedSource); 00844 } 00845 00846 private: 00847 00848 XalanTransformer& m_transformer; 00849 00850 const XalanParsedSource* const m_parsedSource; 00851 }; 00852 00853 struct EnsureDestroyCompiledStylesheet 00854 { 00855 EnsureDestroyCompiledStylesheet( 00856 XalanTransformer& theTransformer, 00857 const XalanCompiledStylesheet* theCompiledStylesheet) : 00858 m_transformer(theTransformer), 00859 m_compiledStylesheet(theCompiledStylesheet) 00860 { 00861 } 00862 00863 ~EnsureDestroyCompiledStylesheet() 00864 { 00865 m_transformer.destroyStylesheet(m_compiledStylesheet); 00866 } 00867 00868 private: 00869 00870 XalanTransformer& m_transformer; 00871 00872 const XalanCompiledStylesheet* const m_compiledStylesheet; 00873 }; 00874 00875 struct EnsureDestroyDocumentBuilder 00876 { 00877 EnsureDestroyDocumentBuilder( 00878 XalanTransformer& theTransformer, 00879 XalanDocumentBuilder* theDocumentBuilder) : 00880 m_transformer(theTransformer), 00881 m_documentBuilder(theDocumentBuilder) 00882 { 00883 } 00884 00885 ~EnsureDestroyDocumentBuilder() 00886 { 00887 m_transformer.destroyDocumentBuilder(m_documentBuilder); 00888 } 00889 00890 private: 00891 00892 XalanTransformer& m_transformer; 00893 00894 XalanDocumentBuilder* const m_documentBuilder; 00895 }; 00896 00897 protected: 00898 00899 private: 00900 00901 void 00902 reset(); 00903 00904 class EnsureReset 00905 { 00906 public: 00907 00908 EnsureReset(XalanTransformer& theTransformer) : 00909 m_transformer(theTransformer) 00910 { 00911 } 00912 00913 ~EnsureReset(); 00914 00915 private: 00916 00917 XalanTransformer& m_transformer; 00918 }; 00919 00920 friend class EnsureReset; 00921 00922 int 00923 doTransform( 00924 const XalanParsedSource& theParsedXML, 00925 const XalanCompiledStylesheet* theCompiledStylesheet, 00926 const XSLTInputSource* theStylesheetSource, 00927 const XSLTResultTarget& theResultTarget); 00928 00929 00930 // Data members... 00931 CompiledStylesheetPtrVectorType m_compiledStylesheets; 00932 00933 ParsedSourcePtrVectorType m_parsedSources; 00934 00935 ParamPairVectorType m_paramPairs; 00936 00937 FunctionParamPairVectorType m_functionPairs; 00938 00939 TraceListenerVectorType m_traceListeners; 00940 00941 CharVectorType m_errorMessage; 00942 00943 bool m_useValidation; 00944 00945 EntityResolverType* m_entityResolver; 00946 00947 ErrorHandlerType* m_errorHandler; 00948 00949 XalanDOMString m_externalSchemaLocation; 00950 00951 XalanDOMString m_externalNoNamespaceSchemaLocation; 00952 00953 ProblemListener* m_problemListener; 00954 00955 StreamType* m_warningStream; 00956 00957 // This should always be the latest data member!!! 00958 StylesheetExecutionContextDefault* m_stylesheetExecutionContext; 00959 00960 static const XSLTInputSource s_emptyInputSource; 00961 00962 static const XSLTInit* s_xsltInit; 00963 }; 00964 00965 00966 00967 XALAN_CPP_NAMESPACE_END 00968 00969 00970 00971 #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.5 |
|