00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 2001 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_OLD_STREAMS) 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 class EntityResolver; 00088 class ErrorHandler; 00089 class Function; 00090 class StylesheetExecutionContextDefault; 00091 class ProblemListener; 00092 class TraceListener; 00093 class XSLTInit; 00094 class XalanDocumentBuilder; 00095 class XalanCompiledStylesheet; 00096 class XalanParsedSource; 00097 class XalanTransformerOutputStream; 00098 00099 00100 00107 class XALAN_TRANSFORMER_EXPORT XalanTransformer 00108 { 00109 public: 00110 00111 #if defined(XALAN_NO_NAMESPACES) 00112 typedef ostream StreamType; 00113 #else 00114 typedef std::ostream StreamType; 00115 #endif 00116 00117 XalanTransformer(); 00118 00119 virtual 00120 ~XalanTransformer(); 00121 00128 static void 00129 initialize(); 00130 00141 static void 00142 terminate(); 00143 00158 static void 00159 ICUCleanUp(); 00160 00170 int 00171 transform( 00172 const XalanParsedSource& theParsedXML, 00173 const XSLTInputSource& theStylesheetSource, 00174 const XSLTResultTarget& theResultTarget) 00175 { 00176 return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget); 00177 } 00178 00188 int 00189 transform( 00190 const XalanParsedSource& theParsedXML, 00191 const XalanCompiledStylesheet* theCompiledStylesheet, 00192 const XSLTResultTarget& theResultTarget) 00193 { 00194 assert(theCompiledStylesheet != 0); 00195 00196 return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget); 00197 } 00198 00210 int 00211 transform( 00212 const XSLTInputSource& theInputSource, 00213 const XSLTInputSource& theStylesheetSource, 00214 const XSLTResultTarget& theResultTarget); 00215 00226 int 00227 transform( 00228 const XSLTInputSource& theInputSource, 00229 const XSLTResultTarget& theResultTarget); 00230 00249 int 00250 transform( 00251 const XSLTInputSource& theInputSource, 00252 const XSLTInputSource& theStylesheetSource, 00253 void* theOutputHandle, 00254 XalanOutputHandlerType theOutputHandler, 00255 XalanFlushHandlerType theFlushHandler = 0); 00256 00268 int 00269 transform( 00270 const XSLTInputSource& theInputSource, 00271 const XalanCompiledStylesheet* theCompiledStylesheet, 00272 const XSLTResultTarget& theResultTarget); 00273 00292 int 00293 transform( 00294 const XalanParsedSource& theParsedSource, 00295 const XalanCompiledStylesheet* theCompiledStylesheet, 00296 void* theOutputHandle, 00297 XalanOutputHandlerType theOutputHandler, 00298 XalanFlushHandlerType theFlushHandler = 0); 00299 00317 int 00318 transform( 00319 const XSLTInputSource& theInputSource, 00320 void* theOutputHandle, 00321 XalanOutputHandlerType theOutputHandler, 00322 XalanFlushHandlerType theFlushHandler = 0); 00323 00336 int 00337 compileStylesheet( 00338 const XSLTInputSource& theStylesheetSource, 00339 const XalanCompiledStylesheet*& theCompiledStylesheet); 00340 00348 int 00349 destroyStylesheet(const XalanCompiledStylesheet* theStylesheet); 00350 00364 int 00365 parseSource( 00366 const XSLTInputSource& theInputSource, 00367 const XalanParsedSource*& theParsedSource, 00368 bool useXercesDOM = false); 00369 00376 int 00377 destroyParsedSource(const XalanParsedSource* theParsedSource); 00378 00388 XalanDocumentBuilder* 00389 createDocumentBuilder(); 00390 00398 void 00399 destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder); 00400 00408 void 00409 installExternalFunction( 00410 const XalanDOMString& theNamespace, 00411 const XalanDOMString& functionName, 00412 const Function& function); 00413 00421 static void 00422 installExternalFunctionGlobal( 00423 const XalanDOMString& theNamespace, 00424 const XalanDOMString& functionName, 00425 const Function& function); 00426 00433 void 00434 uninstallExternalFunction( 00435 const XalanDOMString& theNamespace, 00436 const XalanDOMString& functionName); 00437 00444 static void 00445 uninstallExternalFunctionGlobal( 00446 const XalanDOMString& theNamespace, 00447 const XalanDOMString& functionName); 00448 00456 void 00457 setStylesheetParam( 00458 const XalanDOMString& key, 00459 const XalanDOMString& expression); 00460 00468 void 00469 setStylesheetParam( 00470 const char* key, 00471 const char* expression); 00472 00480 void 00481 addTraceListener(TraceListener* theTraceListener) 00482 { 00483 m_traceListeners.push_back(theTraceListener); 00484 } 00485 00492 bool 00493 removeTraceListener(TraceListener* theTraceListener); 00494 00498 void 00499 removeTraceListeners() 00500 { 00501 m_traceListeners.clear(); 00502 } 00503 00510 bool 00511 getUseValidation() const 00512 { 00513 return m_useValidation; 00514 } 00515 00522 void 00523 setUseValidation(bool fValue) 00524 { 00525 m_useValidation = fValue; 00526 } 00527 00533 EntityResolver* 00534 getEntityResolver() const 00535 { 00536 return m_entityResolver; 00537 } 00538 00548 void 00549 setEntityResolver(EntityResolver* theResolver) 00550 { 00551 m_entityResolver = theResolver; 00552 } 00553 00559 ErrorHandler* 00560 getErrorHandler() const 00561 { 00562 return m_errorHandler; 00563 } 00564 00570 void 00571 setErrorHandler(ErrorHandler* theErrorHandler) 00572 { 00573 m_errorHandler = theErrorHandler; 00574 } 00575 00582 const XalanDOMChar* 00583 getExternalSchemaLocation() const 00584 { 00585 return m_externalSchemaLocation.size() == 0 ? 0 : m_externalSchemaLocation.c_str(); 00586 } 00587 00594 void 00595 setExternalSchemaLocation(const XalanDOMChar* location) 00596 { 00597 assert(location != 0); 00598 00599 m_externalSchemaLocation = location; 00600 } 00601 00608 const XalanDOMChar* 00609 getExternalNoNamespaceSchemaLocation() const 00610 { 00611 return m_externalNoNamespaceSchemaLocation.size() == 0 ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); 00612 } 00613 00620 void 00621 setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) 00622 { 00623 assert(location != 0); 00624 00625 m_externalNoNamespaceSchemaLocation = location; 00626 } 00627 00633 ProblemListener* 00634 getProblemListener() const 00635 { 00636 return m_problemListener; 00637 } 00638 00644 void 00645 setProblemListener(ProblemListener* theProblemListener) 00646 { 00647 m_problemListener = theProblemListener; 00648 } 00649 00656 const char* 00657 getLastError() const; 00658 00664 int 00665 getIndent() const; 00666 00672 void 00673 setIndent(int indentAmount); 00674 00678 enum eEscapeURLs 00679 { 00680 eEscapeURLsDefault, // Use the value in the stylesheet 00681 eEscapeURLsNo, // Don't escape URLs 00682 eEscapeURLsYes // Escape URLs 00683 }; 00684 00692 eEscapeURLs 00693 getEscapeURLs() const; 00694 00702 void 00703 setEscapeURLs(eEscapeURLs value); 00704 00708 enum eOmitMETATag 00709 { 00710 eOmitMETATagDefault, // Use the value in the stylesheet 00711 eOmitMETATagNo, // Don't omit the META tag 00712 eOmitMETATagYes // Omit the META tag 00713 }; 00714 00722 eOmitMETATag 00723 getOmitMETATag() const; 00724 00732 void 00733 setOmitMETATag(eOmitMETATag value); 00734 00741 void 00742 setWarningStream(StreamType* theStream) 00743 { 00744 m_warningStream = theStream; 00745 } 00746 00752 StreamType* 00753 getWarningStream() const 00754 { 00755 return m_warningStream; 00756 } 00757 00758 #if defined(XALAN_NO_NAMESPACES) 00759 typedef vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00760 typedef vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00761 typedef pair<XalanDOMString, XalanDOMString> ParamPairType; 00762 typedef vector<ParamPairType> ParamPairVectorType; 00763 typedef pair<XalanQNameByValue, Function*> FunctionPairType; 00764 typedef vector<FunctionPairType> FunctionParamPairVectorType; 00765 typedef vector<TraceListener*> TraceListenerVectorType; 00766 #else 00767 typedef std::vector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00768 typedef std::vector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00769 typedef std::pair<XalanDOMString, XalanDOMString> ParamPairType; 00770 typedef std::vector<ParamPairType> ParamPairVectorType; 00771 typedef std::pair<XalanQNameByValue, Function*> FunctionPairType; 00772 typedef std::vector<FunctionPairType> FunctionParamPairVectorType; 00773 typedef std::vector<TraceListener*> TraceListenerVectorType; 00774 #endif 00775 00776 class EnsureDestroyParsedSource 00777 { 00778 public: 00779 00780 EnsureDestroyParsedSource( 00781 XalanTransformer& theTransformer, 00782 const XalanParsedSource* theParsedSource) : 00783 m_transformer(theTransformer), 00784 m_parsedSource(theParsedSource) 00785 { 00786 } 00787 00788 ~EnsureDestroyParsedSource() 00789 { 00790 m_transformer.destroyParsedSource(m_parsedSource); 00791 } 00792 00793 private: 00794 00795 XalanTransformer& m_transformer; 00796 00797 const XalanParsedSource* const m_parsedSource; 00798 }; 00799 00800 struct EnsureDestroyCompiledStylesheet 00801 { 00802 EnsureDestroyCompiledStylesheet( 00803 XalanTransformer& theTransformer, 00804 const XalanCompiledStylesheet* theCompiledStylesheet) : 00805 m_transformer(theTransformer), 00806 m_compiledStylesheet(theCompiledStylesheet) 00807 { 00808 } 00809 00810 ~EnsureDestroyCompiledStylesheet() 00811 { 00812 m_transformer.destroyStylesheet(m_compiledStylesheet); 00813 } 00814 00815 private: 00816 00817 XalanTransformer& m_transformer; 00818 00819 const XalanCompiledStylesheet* const m_compiledStylesheet; 00820 }; 00821 00822 struct EnsureDestroyDocumentBuilder 00823 { 00824 EnsureDestroyDocumentBuilder( 00825 XalanTransformer& theTransformer, 00826 XalanDocumentBuilder* theDocumentBuilder) : 00827 m_transformer(theTransformer), 00828 m_documentBuilder(theDocumentBuilder) 00829 { 00830 } 00831 00832 ~EnsureDestroyDocumentBuilder() 00833 { 00834 m_transformer.destroyDocumentBuilder(m_documentBuilder); 00835 } 00836 00837 private: 00838 00839 XalanTransformer& m_transformer; 00840 00841 XalanDocumentBuilder* const m_documentBuilder; 00842 }; 00843 00844 protected: 00845 00846 private: 00847 00848 void 00849 reset(); 00850 00851 class EnsureReset 00852 { 00853 public: 00854 00855 EnsureReset(XalanTransformer& theTransformer) : 00856 m_transformer(theTransformer) 00857 { 00858 } 00859 00860 ~EnsureReset(); 00861 00862 private: 00863 00864 XalanTransformer& m_transformer; 00865 }; 00866 00867 friend class EnsureReset; 00868 00869 int 00870 doTransform( 00871 const XalanParsedSource& theParsedXML, 00872 const XalanCompiledStylesheet* theCompiledStylesheet, 00873 const XSLTInputSource* theStylesheetSource, 00874 const XSLTResultTarget& theResultTarget); 00875 00876 00877 // Data members... 00878 CompiledStylesheetPtrVectorType m_compiledStylesheets; 00879 00880 ParsedSourcePtrVectorType m_parsedSources; 00881 00882 ParamPairVectorType m_paramPairs; 00883 00884 FunctionParamPairVectorType m_functionPairs; 00885 00886 TraceListenerVectorType m_traceListeners; 00887 00888 CharVectorType m_errorMessage; 00889 00890 bool m_useValidation; 00891 00892 EntityResolver* m_entityResolver; 00893 00894 ErrorHandler* m_errorHandler; 00895 00896 XalanDOMString m_externalSchemaLocation; 00897 00898 XalanDOMString m_externalNoNamespaceSchemaLocation; 00899 00900 ProblemListener* m_problemListener; 00901 00902 StreamType* m_warningStream; 00903 00904 // This should always be the latest data member!!! 00905 StylesheetExecutionContextDefault* m_stylesheetExecutionContext; 00906 00907 static const XSLTInit* s_xsltInit; 00908 }; 00909 00910 00911 00912 #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.4 |
|