00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 00019 #if !defined(XALANTRANSFORMER_HEADER_GUARD) 00020 #define XALANTRANSFORMER_HEADER_GUARD 00021 00022 // Base include file. Must be first. 00023 #include <xalanc/XalanTransformer/XalanTransformerDefinitions.hpp> 00024 00025 00026 00027 #include <cassert> 00028 #if defined(XALAN_CLASSIC_IOSTREAMS) 00029 class ostream; 00030 #else 00031 #include <iosfwd> 00032 #endif 00033 #include <algorithm> 00034 00035 00036 00037 #include <xalanc/Include/XalanVector.hpp> 00038 00039 #include <xalanc/XalanDOM/XalanNode.hpp> 00040 #include <xalanc/Include/XalanMap.hpp> 00041 #include <xalanc/XSLT/XalanParamHolder.hpp> 00042 #include <xalanc/XPath/XObjectFactoryDefault.hpp> 00043 00044 #include <xalanc/XPath/XalanQNameByValue.hpp> 00045 00046 00047 00048 #include <xalanc/XSLT/XSLTInputSource.hpp> 00049 #include <xalanc/XSLT/XSLTResultTarget.hpp> 00050 00051 00052 00053 XALAN_DECLARE_XERCES_CLASS(EntityResolver) 00054 XALAN_DECLARE_XERCES_CLASS(ErrorHandler) 00055 XALAN_DECLARE_XERCES_CLASS(XMLEntityResolver) 00056 00057 00058 00059 XALAN_CPP_NAMESPACE_BEGIN 00060 00061 00062 00063 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType; 00064 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType; 00065 00066 XALAN_USING_XERCES(EntityResolver) 00067 XALAN_USING_XERCES(ErrorHandler) 00068 XALAN_USING_XERCES(XMLEntityResolver) 00069 00070 00071 00072 class Function; 00073 class StylesheetExecutionContextDefault; 00074 class ProblemListener; 00075 class TraceListener; 00076 class XSLTInit; 00077 class XalanDocumentBuilder; 00078 class XalanCompiledStylesheet; 00079 class XalanParsedSource; 00080 class XalanTransformerOutputStream; 00081 00082 class XObjectFactoryDefault; 00083 class XalanNode; 00084 00085 /** 00086 * This is a simple C++ interface for some common usage patterns. It's 00087 * the user's responsibility to call initialize and terminate for Xerces 00088 * and Xalan before creating and after deleting any XalanTransformer 00089 * instances. 00090 */ 00091 class XALAN_TRANSFORMER_EXPORT XalanTransformer 00092 { 00093 00094 public: 00095 00096 #if defined(XALAN_NO_STD_NAMESPACE) 00097 typedef ostream StreamType; 00098 #else 00099 typedef std::ostream StreamType; 00100 #endif 00101 00102 typedef XalanVector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType; 00103 typedef XalanVector<const XalanParsedSource*> ParsedSourcePtrVectorType; 00104 00105 typedef XalanMap<XalanDOMString, XalanParamHolder> ParamMapType; 00106 00107 typedef XalanMap<XalanQNameByValue, Function*> FunctionMapType; 00108 typedef XalanVector<TraceListener*> TraceListenerVectorType; 00109 00110 XalanTransformer(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr()); 00111 00112 virtual 00113 ~XalanTransformer(); 00114 00115 MemoryManager& 00116 getMemoryManager() 00117 { 00118 return m_memoryManager; 00119 } 00120 00121 const MemoryManager& 00122 getMemoryManager() const 00123 { 00124 return m_memoryManager; 00125 } 00126 00127 /** 00128 * Initialize Xalan. 00129 * 00130 * Should be called only once per process before creating any 00131 * instances of XalanTransformer. This call is not thread-safe, 00132 * so you must serialize any calls to it, and you must track the 00133 * initialization state, so you do not call it more than once. 00134 */ 00135 static void 00136 initialize(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr()); 00137 00138 /** 00139 * Terminate Xalan. 00140 * 00141 * Should be called only once per process after deleting all 00142 * instances of XalanTransformer. This call is not thread-safe, 00143 * so you must serialize any calls to it, and you must track the 00144 * initialization state, so you do not call it more than once. 00145 * 00146 * This is handy when using leak-detection software, as all 00147 * static data allocated by Xalan is freed. 00148 * 00149 */ 00150 static void 00151 terminate(); 00152 00153 /** 00154 * Clean up the ICU, if ICU integration is enabled. 00155 * 00156 * This should be called only once per process after calling 00157 * XalanTransformer::terminate() and XMLPlatformUtils::Terminate. 00158 * 00159 * This must only be done if the ICU will no longer be used by 00160 * the process, since the ICU will no longer be in a usable state. 00161 * See the ICU documentation for more details. 00162 * 00163 * This call is not thread-safe, so you must serialize any calls 00164 * to it, and you must track the initialization state, so you do 00165 * not call it more than once. 00166 * 00167 * This is handy when using leak-detection software, as all 00168 * static data allocated by the ICU is freed. 00169 * 00170 */ 00171 static void 00172 ICUCleanUp(); 00173 00174 00175 static void 00176 ICUStartUp(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr()); 00177 00178 /** 00179 * Transform will apply the stylesheet source to the parsed xml source 00180 * and write the transformation output to the target. 00181 * 00182 * @param theParsedXML the parsed input source 00183 * @param theStylesheetSource stylesheet source 00184 * @param theResultTarget output source 00185 * @return 0 for success 00186 */ 00187 int 00188 transform( 00189 const XalanParsedSource& theParsedXML, 00190 const XSLTInputSource& theStylesheetSource, 00191 const XSLTResultTarget& theResultTarget) 00192 { 00193 return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget); 00194 } 00195 00196 /** 00197 * Transform will apply the compiled stylesheet to the parsed xml source 00198 * and write the transformation output to the target. 00199 * 00200 * @param theParsedXML the parsed input source 00201 * @param theCompiledStylesheet pointer to a compiled stylesheet. Must not be null. 00202 * @param theResultTarget output source 00203 * @return 0 for success 00204 */ 00205 int 00206 transform( 00207 const XalanParsedSource& theParsedXML, 00208 const XalanCompiledStylesheet* theCompiledStylesheet, 00209 const XSLTResultTarget& theResultTarget) 00210 { 00211 assert(theCompiledStylesheet != 0); 00212 00213 return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget); 00214 } 00215 00216 /** 00217 * Transform will apply the stylesheet provided as a PI in the 00218 * XML of the parsed xml source and write the transformation output to 00219 * the target. 00220 * 00221 * @param theParsedXML the parsed input source 00222 * @param theResultTarget output source tree 00223 * @return 0 for success 00224 */ 00225 int 00226 transform( 00227 const XalanParsedSource& theParsedXML, 00228 const XSLTResultTarget& theResultTarget) 00229 { 00230 assert(s_emptyInputSource != 0); 00231 00232 return transform(theParsedXML, *s_emptyInputSource, theResultTarget); 00233 } 00234 00235 /** 00236 * Transform will apply the stylesheet source to the input source 00237 * and write the transformation output to the target. The input 00238 * source and result target can be a file name, a stream or a root 00239 * node. 00240 * 00241 * @param theInputSource input source 00242 * @param theStylesheetSource stylesheet source 00243 * @param theResultTarget output source 00244 * @return 0 for success 00245 */ 00246 int 00247 transform( 00248 const XSLTInputSource& theInputSource, 00249 const XSLTInputSource& theStylesheetSource, 00250 const XSLTResultTarget& theResultTarget); 00251 00252 /** 00253 * Transform will apply the stylesheet provided as a PI in the 00254 * XML of the input source and write the transformation output to 00255 * the target. The input source and result target can be a file 00256 * name, a stream or a root node. 00257 * 00258 * @param theInputSource input source 00259 * @param theResultTarget output source tree 00260 * @return 0 for success 00261 */ 00262 int 00263 transform( 00264 const XSLTInputSource& theInputSource, 00265 const XSLTResultTarget& theResultTarget) 00266 { 00267 assert(s_emptyInputSource != 0); 00268 00269 return transform( 00270 theInputSource, 00271 *s_emptyInputSource, 00272 theResultTarget); 00273 } 00274 00275 /** 00276 * Transform will apply the stylesheet source to the input source 00277 * and write the transformation result to a callback function 00278 * in pre-allocated blocks. The input source can be a file name, 00279 * a stream or a root node. Upon termination, Xalan releases any 00280 * allocated memory. Data passed to the callback is not guaranteed to 00281 * be null terminated. 00282 * 00283 * - See XalanTransformerOutputStream and XalanOutputHandlerType 00284 * for more details. 00285 * 00286 * @param theInputSource input source 00287 * @param theStylesheetSource stylesheet source 00288 * @param theOutputHandle void pointer passed through to callback. 00289 * @param theOutputHandler a user defined (callback) function. 00290 * @param theFlushHandler (optional) a user defined (callback) function. 00291 * @return 0 for success 00292 */ 00293 int 00294 transform( 00295 const XSLTInputSource& theInputSource, 00296 const XSLTInputSource& theStylesheetSource, 00297 void* theOutputHandle, 00298 XalanOutputHandlerType theOutputHandler, 00299 XalanFlushHandlerType theFlushHandler = 0); 00300 00301 /** 00302 * Transform will apply the compiled stylesheet to the input source 00303 * and write the transformation output to the target. The input 00304 * source and result target can be a file name, a stream or a root 00305 * node. 00306 * 00307 * @param theInputSource input source 00308 * @param theCompiledStylesheet pointer to a compiled stylesheet. Must not be null. 00309 * @param theResultTarget output source 00310 * @return 0 for success 00311 */ 00312 int 00313 transform( 00314 const XSLTInputSource& theInputSource, 00315 const XalanCompiledStylesheet* theCompiledStylesheet, 00316 const XSLTResultTarget& theResultTarget); 00317 00318 /** 00319 * Transform will apply the compiled stylesheet to the source 00320 * and write the transformation result to a callback function 00321 * in pre-allocated blocks. The input source can be a file name, 00322 * a stream or a root node. Upon termination, Xalan releases any 00323 * allocated memory. Data passed to the callback is not guaranteed to 00324 * be null terminated. 00325 * 00326 * - See XalanTransformerOutputStream and XalanOutputHandlerType 00327 * for more details. 00328 * 00329 * @param theParsedSource Parsed source instance 00330 * @param theCompiledStylesheet pointer to a compiled stylesheet. Must not be null. 00331 * @param theOutputHandle void pointer passed through to callback. 00332 * @param theOutputHandler a user defined callback function. 00333 * @param theFlushHandler An optional user-defined callback function. 00334 * @return 0 for success 00335 */ 00336 int 00337 transform( 00338 const XalanParsedSource& theParsedSource, 00339 const XalanCompiledStylesheet* theCompiledStylesheet, 00340 void* theOutputHandle, 00341 XalanOutputHandlerType theOutputHandler, 00342 XalanFlushHandlerType theFlushHandler = 0); 00343 00344 /** 00345 * Transform will apply the stylesheet provided as a PI in the 00346 * XML of the input source and write the transformation result to a 00347 * callback function in pre-allocated blocks. The input source can be 00348 * a file name, a stream or a root node. Upon termination, Xalan 00349 * releases any allocated memory. Data passed to the callback is not 00350 * guaranteed to be null terminated. 00351 * 00352 * - See XalanTransformerOutputStream and XalanOutputHandlerType 00353 * for more details. 00354 * 00355 * @param theInputSource input source 00356 * @param theOutputHandle void pointer passed through to callback. 00357 * @param theOutputHandler a user defined callback function. 00358 * @param theFlushHandler an optional user-defined callback function. 00359 * @return 0 for success 00360 */ 00361 int 00362 transform( 00363 const XSLTInputSource& theInputSource, 00364 void* theOutputHandle, 00365 XalanOutputHandlerType theOutputHandler, 00366 XalanFlushHandlerType theFlushHandler = 0); 00367 00368 /** 00369 * Creates a compiled stylesheet. The input source can be 00370 * a file name, a stream or a root node. The XalanTransformer 00371 * instance owns the XalanCompiledStylesheet instance and will 00372 * delete it when the XalanTransformer instance goes out of scope, 00373 * or you explicitly call destroyStylesheet(). You must not delete 00374 * the instance yourself. 00375 * 00376 * @param theStylesheetSource input source 00377 * @param theCompiledStylesheet a reference to a pointer to a XalanCompileStylesheet. 00378 * @return 0 for success 00379 */ 00380 int 00381 compileStylesheet( 00382 const XSLTInputSource& theStylesheetSource, 00383 const XalanCompiledStylesheet*& theCompiledStylesheet); 00384 00385 /** 00386 * Destroy a XalanCompiledStylesheet instance created by a previous 00387 * call to compileStylesheet(). 00388 * 00389 * @param theStylesheet The instance to destroy. 00390 * @return 0 for success 00391 */ 00392 int 00393 destroyStylesheet(const XalanCompiledStylesheet* theStylesheet); 00394 00395 /** 00396 * Parse a source XML document. The input source can be 00397 * a file name, a stream or a root node. The XalanTransformer 00398 * instance owns the XalanParsedSource instance and will 00399 * delete it when the XalanTransformer instance goes out of scope, 00400 * or you explicitly call destroyParsedSource(). You must not 00401 * delete the instance yourself. 00402 * 00403 * @param theInputSource input source 00404 * @param theParsedSource a reference to a pointer to a XalanParsedSource. 00405 * @param useXercesDOM input use default or xerces DOM source tree 00406 * @return 0 for success 00407 */ 00408 int 00409 parseSource( 00410 const XSLTInputSource& theInputSource, 00411 const XalanParsedSource*& theParsedSource, 00412 bool useXercesDOM = false); 00413 00414 /** 00415 * Destroy a parsed source created by a previous call to parseSource(). 00416 * 00417 * @param theParsedSource The XalanParsedSource instance to destroy. 00418 * @return 0 for success 00419 */ 00420 int 00421 destroyParsedSource(const XalanParsedSource* theParsedSource); 00422 00423 /** 00424 * Create a document builder. Using the document builder, you 00425 * can construct a document using SAX2 interfaces. The XalanTransformer 00426 * instance owns the document builder and will delete it when the 00427 * XalanTransformer instance goes out of scope, or you explicitly call 00428 * destroyDocumentBuilder(). You must not delete the instance yourself. 00429 * 00430 * @param theURI The base URI for the document instance. 00431 * @return a pointer to a XalanDocumentBuilder instance or 0 for failure. 00432 */ 00433 XalanDocumentBuilder* 00434 createDocumentBuilder(const XalanDOMString& theURI = XalanDOMString(XalanMemMgrs::getDummyMemMgr())); 00435 00436 /** 00437 * Destroy a document builder created by a previous call to createDocumentBuilder(). 00438 * Passing a pointer that is not created by a call to createDocumentBuilder() can 00439 * result in undefined behavior. 00440 * 00441 * @param theDocumentBuilder The document builder to destroy. 00442 */ 00443 void 00444 destroyDocumentBuilder(XalanDocumentBuilder* theDocumentBuilder); 00445 00446 /** 00447 * Install an external function in the local space. 00448 * 00449 * @param theNamespace The namespace for the functionl 00450 * @param functionName The name of the function. 00451 * @param function The function to install. 00452 */ 00453 void 00454 installExternalFunction( 00455 const XalanDOMString& theNamespace, 00456 const XalanDOMString& functionName, 00457 const Function& function); 00458 00459 /** 00460 * Install an external function in the global space. 00461 * 00462 * @param theNamespace The namespace for the functionl 00463 * @param functionName The name of the function. 00464 * @param function The function to install. 00465 */ 00466 static void 00467 installExternalFunctionGlobal( 00468 const XalanDOMString& theNamespace, 00469 const XalanDOMString& functionName, 00470 const Function& function); 00471 00472 /** 00473 * Uninstall an external local function. 00474 * 00475 * @param theNamespace The namespace for the function 00476 * @param functionName The name of the function. 00477 */ 00478 void 00479 uninstallExternalFunction( 00480 const XalanDOMString& theNamespace, 00481 const XalanDOMString& functionName); 00482 00483 /** 00484 * Uninstall an external global function. 00485 * 00486 * @param theNamespace The namespace for the function 00487 * @param functionName The name of the function. 00488 */ 00489 static void 00490 uninstallExternalFunctionGlobal( 00491 const XalanDOMString& theNamespace, 00492 const XalanDOMString& functionName); 00493 00494 /** 00495 * Retrieve the factory object for creating XObjects. 00496 * 00497 * @return factory object instance 00498 */ 00499 XObjectFactory& 00500 getXObjectFactory() const 00501 { 00502 assert(m_topXObjectFactory != 0); 00503 00504 return *m_topXObjectFactory; 00505 } 00506 00507 /** 00508 * Set a top-level parameter, which the stylesheet can access 00509 * with a top-level xsl:param. Top-level params are "sticky," 00510 * and must be removed with a call to clearStylesheetParams(). 00511 * 00512 * @param key name of the param 00513 * @param expression expression that will be evaluated 00514 */ 00515 void 00516 setStylesheetParam( 00517 const XalanDOMString& key, 00518 const XalanDOMString& expression); 00519 00520 /** 00521 * Set a top-level parameter, which the stylesheet can access 00522 * with a top-level xsl:param. Top-level params are "sticky," 00523 * and must be removed with a call to clearStylesheetParams(). 00524 * 00525 * @param key name of the param 00526 * @param expression expression that will be evaluated 00527 */ 00528 void 00529 setStylesheetParam( 00530 const char* key, 00531 const char* expression); 00532 00533 /** 00534 * Set a top-level parameter, which the stylesheet can access 00535 * with a top-level xsl:param. Top-level params are "sticky," 00536 * and must be removed with a call to clearStylesheetParams(). 00537 * 00538 * @param key name of the param 00539 * @param number value to be evaluated 00540 */ 00541 void 00542 setStylesheetParam( 00543 const char* key, 00544 double number); 00545 00546 /** 00547 * Set a top-level parameter, which the stylesheet can access 00548 * with a top-level xsl:param. Top-level params are "sticky," 00549 * and must be removed with a call to clearStylesheetParams(). 00550 * 00551 * @param key name of the param 00552 * @param number value to be evaluated 00553 */ 00554 void 00555 setStylesheetParam( 00556 const XalanDOMString& key, 00557 double number); 00558 00559 /** 00560 * Set a top-level parameter, which the stylesheet can access 00561 * with a top-level xsl:param. Top-level params are "sticky," 00562 * and must be removed with a call to clearStylesheetParams(). 00563 * 00564 * @param key name of the param 00565 * @param nodeset XML nodeset that will be evaulated 00566 */ 00567 void 00568 setStylesheetParam( 00569 const char* key, 00570 XalanNode* nodeset); 00571 00572 /** 00573 * Set a top-level parameter, which the stylesheet can access 00574 * with a top-level xsl:param. Top-level params are "sticky," 00575 * and must be removed with a call to clearStylesheetParams(). 00576 * 00577 * @param key name of the param 00578 * @param nodeset XML nodeset that will be evaluated 00579 */ 00580 void 00581 setStylesheetParam( 00582 const XalanDOMString& key, 00583 XalanNode* nodeset); 00584 00585 /** 00586 * Set a top-level parameter, which the stylesheet can access 00587 * with a top-level xsl:param. Top-level params are "sticky," 00588 * and must be removed with a call to clearStylesheetParams(). 00589 * 00590 * @param key name of the param 00591 * @param object any XObject owned by the transformer 00592 */ 00593 void 00594 setStylesheetParam( 00595 const char* key, 00596 XObjectPtr object); 00597 00598 /** 00599 * Set a top-level parameter, which the stylesheet can access 00600 * with a top-level xsl:param. Top-level params are "sticky," 00601 * and must be removed with a call to clearStylesheetParams(). 00602 * 00603 * @param key name of the param 00604 * @param object any XObject owned by the transformer 00605 */ 00606 void 00607 setStylesheetParam( 00608 const XalanDOMString& key, 00609 XObjectPtr object); 00610 00611 /** 00612 * Clear any stylesheet params. 00613 */ 00614 void 00615 clearStylesheetParams() 00616 { 00617 m_params.clear(); 00618 m_topXObjectFactory->reset(); 00619 } 00620 00621 /** 00622 * Add a TraceListener instance. TraceListeners instances are preserved 00623 * between calls to transform(), so they will be called until they are 00624 * removed. 00625 * 00626 * @param theTraceListener The instance to add. 00627 */ 00628 void 00629 addTraceListener(TraceListener* theTraceListener) 00630 { 00631 m_traceListeners.push_back(theTraceListener); 00632 } 00633 00634 /** 00635 * Remove a TraceListener instance 00636 * 00637 * @param theTraceListener The instance to remove. 00638 * @return true if the instance was removed, false if not. 00639 */ 00640 bool 00641 removeTraceListener(TraceListener* theTraceListener); 00642 00643 /** 00644 * Remove all TraceListener instances. 00645 */ 00646 void 00647 removeTraceListeners() 00648 { 00649 m_traceListeners.clear(); 00650 } 00651 00652 /** 00653 * Set a flag to indicate whether or not the source file(s) for the 00654 * transformation will be validated. 00655 * 00656 * @param fValue the new value for the flag. 00657 */ 00658 bool 00659 getUseValidation() const 00660 { 00661 return m_useValidation; 00662 } 00663 00664 /** 00665 * Set a flag to indicate whether or not the source file(s) for the 00666 * transformation will be validated. 00667 * 00668 * @param fValue the new value for the flag. 00669 */ 00670 void 00671 setUseValidation(bool fValue) 00672 { 00673 m_useValidation = fValue; 00674 } 00675 00676 /** 00677 * Returns the installed EntityResolver. 00678 * 00679 * @return The pointer to the installed EntityResolver. 00680 */ 00681 EntityResolver* 00682 getEntityResolver() const 00683 { 00684 return m_entityResolver; 00685 } 00686 00687 /** 00688 * Installs the supplied EntityResolver. 00689 * 00690 * A call to setEntityResolver with a non-null pointer will 00691 * uninstall any XMLEntityResolver previously installed. 00692 * 00693 * @param theResolver A pointer to the EntityResolver. 00694 */ 00695 void 00696 setEntityResolver(EntityResolver* theResolver) 00697 { 00698 m_entityResolver = theResolver; 00699 00700 if (theResolver != 0 && m_xmlEntityResolver != 0) 00701 { 00702 m_xmlEntityResolver = 0; 00703 } 00704 } 00705 00706 /** 00707 * Returns the installed XMLEntityResolver. 00708 * 00709 * @return The pointer to the installed XMLEntityResolver. 00710 */ 00711 XMLEntityResolver* 00712 getXMLEntityResolver() const 00713 { 00714 return m_xmlEntityResolver; 00715 } 00716 00717 /** 00718 * Installs the supplied XMLEntityResolver. 00719 * 00720 * A call to setXMLEntityResolver with a non-null pointer will 00721 * uninstall any EntityResolver previously installed. 00722 * 00723 * @param theResolver A pointer to the XMLEntityResolver. 00724 */ 00725 void 00726 setXMLEntityResolver(XMLEntityResolver* theResolver) 00727 { 00728 m_xmlEntityResolver = theResolver; 00729 00730 if (theResolver != 0 && m_entityResolver != 0) 00731 { 00732 m_entityResolver = 0; 00733 } 00734 } 00735 00736 /** 00737 * This method returns the installed error handler. 00738 * 00739 * @return The pointer to the installed error handler object. 00740 */ 00741 ErrorHandler* 00742 getErrorHandler() const 00743 { 00744 return m_errorHandler; 00745 } 00746 00747 /** 00748 * This method installs the user-specified error handler. 00749 * 00750 * @param handler A pointer to the error handler to be called upon error. 00751 */ 00752 void 00753 setErrorHandler(ErrorHandler* theErrorHandler) 00754 { 00755 m_errorHandler = theErrorHandler; 00756 } 00757 00758 /** 00759 * This method returns the location for an external schema document 00760 * for parsing. 00761 * 00762 * @return A string representing the location of the external schema document 00763 */ 00764 const XalanDOMChar* 00765 getExternalSchemaLocation() const 00766 { 00767 return m_externalSchemaLocation.empty() == true ? 0 : m_externalSchemaLocation.c_str(); 00768 } 00769 00770 /** 00771 * This method sets the location for an external schema document 00772 * for parsing. 00773 * 00774 * @param location A string representing the location of the external schema document 00775 */ 00776 void 00777 setExternalSchemaLocation(const XalanDOMChar* location) 00778 { 00779 assert(location != 0); 00780 00781 m_externalSchemaLocation = location; 00782 } 00783 00784 /** 00785 * This method returns the location for an external schema document 00786 * for parsing. 00787 * 00788 * @return A string representing the location of the external schema document 00789 */ 00790 const XalanDOMChar* 00791 getExternalNoNamespaceSchemaLocation() const 00792 { 00793 return m_externalNoNamespaceSchemaLocation.empty() == true ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); 00794 } 00795 00796 /** 00797 * This method sets the location for an external schema document 00798 * for parsing. 00799 * 00800 * @param location A string representing the location of the external schema document 00801 */ 00802 void 00803 setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) 00804 { 00805 assert(location != 0); 00806 00807 m_externalNoNamespaceSchemaLocation = location; 00808 } 00809 00810 /** 00811 * This member functions gets the flag to determine of a default parsed source 00812 * tree will pool the values of all of the text nodes in the XML document. 00813 * 00814 * @return The boolean value for the flag. 00815 */ 00816 bool 00817 getPoolAllTextNodes() const 00818 { 00819 return m_poolAllTextNodes; 00820 } 00821 00822 /** 00823 * This member functions sets the flag to determine of a default parsed source 00824 * tree will pool the values of all of the text nodes in the XML document. This 00825 * can result in significant memory savings if there are lots of repeated values 00826 * in text nodes. 00827 * 00828 * @param fPool The boolean value for the flag. 00829 */ 00830 void 00831 setPoolAllTextNodes(bool fPool) 00832 { 00833 m_poolAllTextNodes = fPool; 00834 } 00835 00836 /** 00837 * This method returns the installed ProblemListener instance. 00838 * 00839 * @return The pointer to the installed ProblemListener instance. 00840 */ 00841 ProblemListener* 00842 getProblemListener() const 00843 { 00844 return m_problemListener; 00845 } 00846 00847 /** 00848 * This method installs the user-specified ProblemListener instance. 00849 * 00850 * @param handler A pointer to the ProblemListener to be called when a problem occurs. 00851 */ 00852 void 00853 setProblemListener(ProblemListener* theProblemListener) 00854 { 00855 m_problemListener = theProblemListener; 00856 } 00857 00858 /** 00859 * Returns the last error that occurred as a 00860 * result of calling transform. 00861 * 00862 * @return error message const character pointer. 00863 */ 00864 const char* 00865 getLastError() const 00866 { 00867 assert(m_errorMessage.empty() == false); 00868 00869 return &m_errorMessage[0]; 00870 } 00871 00872 /** 00873 * Get the current output encoding, if any. Note this is not the output encoding 00874 * specified in a stylesheet. Rather, it can override that encoding, if the 00875 * 00876 * @return A string containing the current encoding 00877 */ 00878 const XalanDOMString& 00879 getOutputEncoding() const 00880 { 00881 return m_outputEncoding; 00882 } 00883 00884 /** 00885 * Set the current output encoding. Note this will override the encoding 00886 * specified in the stylesheet, if the encoding is available. However, 00887 * it will not override any encoding specified by an XSLTResultTarget 00888 * parameter to one of the transform() member functions. 00889 * 00890 * @param theEncoding The encoding to use. 00891 */ 00892 void 00893 setOutputEncoding(const XalanDOMString& theEncoding) 00894 { 00895 m_outputEncoding = theEncoding; 00896 } 00897 00898 /** 00899 * Get the current number of spaces to indent. 00900 * 00901 * @return number of spaces 00902 */ 00903 int 00904 getIndent() const; 00905 00906 /** 00907 * Set the current number of spaces to indent. 00908 * 00909 * @param indentAmount The number of spaces to indent. Use -1 for the default amount. 00910 */ 00911 void 00912 setIndent(int indentAmount); 00913 00914 /** 00915 * Enums to determine whether or not run-time escaping of URLs has been set. 00916 */ 00917 enum eEscapeURLs 00918 { 00919 eEscapeURLsDefault, // Use the value in the stylesheet 00920 eEscapeURLsNo, // Don't escape URLs 00921 eEscapeURLsYes // Escape URLs 00922 }; 00923 00924 /** 00925 * Get the value for run-time escaping of URLs. This can 00926 * override the property specified by the stylesheet. The 00927 * default behavior is to honor the property in the stylesheet. 00928 * 00929 * @return The value of the enum 00930 */ 00931 eEscapeURLs 00932 getEscapeURLs() const; 00933 00934 /** 00935 * Set the value for run-time escaping of URLs. This can 00936 * override the property specified by the stylesheet. The 00937 * default behavior is to honor the property in the stylesheet. 00938 * 00939 * @param value The value of the enum 00940 */ 00941 void 00942 setEscapeURLs(eEscapeURLs value); 00943 00944 /** 00945 * Enums to determine whether or not run-time omission of the META tag has been set. 00946 * Relevant only for HTML output 00947 */ 00948 enum eOmitMETATag 00949 { 00950 eOmitMETATagDefault, // Use the value in the stylesheet 00951 eOmitMETATagNo, // Don't omit the META tag 00952 eOmitMETATagYes // Omit the META tag 00953 }; 00954 00955 /** 00956 * Get the value for run-time omission of the META tag. This can 00957 * override the property specified by the stylesheet. The 00958 * default behavior is to honor the property in the stylesheet. 00959 * 00960 * @return The value of the enum 00961 */ 00962 eOmitMETATag 00963 getOmitMETATag() const; 00964 00965 /** 00966 * Get the value for run-time omission of the META tag. This can 00967 * override the property specified by the stylesheet. The 00968 * default behavior is to honor the property in the stylesheet. 00969 * 00970 * @param value The value of the enum 00971 */ 00972 void 00973 setOmitMETATag(eOmitMETATag value); 00974 00975 /** 00976 * Set the ostream instance for reporting errors. The default 00977 * is a null pointer, so errors are not reported. If there is 00978 * a user-installed ProblemListener instance, this is not used, as 00979 * all such warnings and messages are handled by the that 00980 * ProblemListener. 00981 * 00982 * @param theStream A pointer to the ostream instance. 00983 */ 00984 void 00985 setErrorStream(StreamType* theStream) 00986 { 00987 m_errorStream = theStream; 00988 } 00989 00990 /** 00991 * Get the current error stream ostream instance. 00992 * 00993 * @return A pointer to the instance. Can be a null pointer. 00994 */ 00995 StreamType* 00996 getErrorStream() const 00997 { 00998 return m_errorStream; 00999 } 01000 01001 /** 01002 * Set the ostream instance for reporting warnings and messages. The default 01003 * is std::cerr. If set to a null pointer, no warnings or messages are written. 01004 * If there is a user-installed ProblemListener instance, this is not used, as 01005 * all such warnings and messages are handled by the that ProblemListener. 01006 * 01007 * @param theStream A pointer to the ostream instance. 01008 */ 01009 void 01010 setWarningStream(StreamType* theStream) 01011 { 01012 m_warningStream = theStream; 01013 } 01014 01015 /** 01016 * Get the current warning stream ostream instance. 01017 * 01018 * @return A pointer to the instance. Can be a null pointer. 01019 */ 01020 StreamType* 01021 getWarningStream() const 01022 { 01023 return m_warningStream; 01024 } 01025 01026 bool 01027 getICUAvailable() const; 01028 01029 class EnsureFunctionsInstallation 01030 { 01031 public: 01032 01033 EnsureFunctionsInstallation(MemoryManager& theManager) : 01034 m_memoryManagement(theManager), 01035 m_release(false) 01036 { 01037 } 01038 01039 ~EnsureFunctionsInstallation(); 01040 01041 void 01042 install(); 01043 01044 void 01045 release() 01046 { 01047 m_release = true; 01048 } 01049 01050 private: 01051 01052 MemoryManager& m_memoryManagement; 01053 01054 bool m_release; 01055 }; 01056 01057 class EnsureDestroyParsedSource 01058 { 01059 public: 01060 01061 EnsureDestroyParsedSource( 01062 XalanTransformer& theTransformer, 01063 const XalanParsedSource* theParsedSource) : 01064 m_transformer(theTransformer), 01065 m_parsedSource(theParsedSource) 01066 { 01067 } 01068 01069 ~EnsureDestroyParsedSource() 01070 { 01071 m_transformer.destroyParsedSource(m_parsedSource); 01072 } 01073 01074 private: 01075 01076 XalanTransformer& m_transformer; 01077 01078 const XalanParsedSource* const m_parsedSource; 01079 }; 01080 01081 class EnsureDestroyCompiledStylesheet 01082 { 01083 public: 01084 01085 EnsureDestroyCompiledStylesheet( 01086 XalanTransformer& theTransformer, 01087 const XalanCompiledStylesheet* theCompiledStylesheet) : 01088 m_transformer(theTransformer), 01089 m_compiledStylesheet(theCompiledStylesheet) 01090 { 01091 } 01092 01093 ~EnsureDestroyCompiledStylesheet() 01094 { 01095 m_transformer.destroyStylesheet(m_compiledStylesheet); 01096 } 01097 01098 private: 01099 01100 XalanTransformer& m_transformer; 01101 01102 const XalanCompiledStylesheet* const m_compiledStylesheet; 01103 }; 01104 01105 struct EnsureDestroyDocumentBuilder 01106 { 01107 EnsureDestroyDocumentBuilder( 01108 XalanTransformer& theTransformer, 01109 XalanDocumentBuilder* theDocumentBuilder) : 01110 m_transformer(theTransformer), 01111 m_documentBuilder(theDocumentBuilder) 01112 { 01113 } 01114 01115 ~EnsureDestroyDocumentBuilder() 01116 { 01117 m_transformer.destroyDocumentBuilder(m_documentBuilder); 01118 } 01119 01120 private: 01121 01122 XalanTransformer& m_transformer; 01123 01124 XalanDocumentBuilder* const m_documentBuilder; 01125 }; 01126 01127 protected: 01128 01129 private: 01130 01131 void 01132 reset(); 01133 01134 class EnsureReset 01135 { 01136 public: 01137 01138 EnsureReset(XalanTransformer& theTransformer) : 01139 m_transformer(theTransformer) 01140 { 01141 } 01142 01143 ~EnsureReset(); 01144 01145 private: 01146 01147 XalanTransformer& m_transformer; 01148 }; 01149 01150 friend class EnsureReset; 01151 01152 int 01153 doTransform( 01154 const XalanParsedSource& theParsedXML, 01155 const XalanCompiledStylesheet* theCompiledStylesheet, 01156 const XSLTInputSource* theStylesheetSource, 01157 const XSLTResultTarget& theResultTarget); 01158 01159 01160 // Data members... 01161 MemoryManager& m_memoryManager; 01162 01163 CompiledStylesheetPtrVectorType m_compiledStylesheets; 01164 01165 ParsedSourcePtrVectorType m_parsedSources; 01166 01167 ParamMapType m_params; 01168 01169 FunctionMapType m_functions; 01170 01171 TraceListenerVectorType m_traceListeners; 01172 01173 CharVectorType m_errorMessage; 01174 01175 bool m_useValidation; 01176 01177 EntityResolver* m_entityResolver; 01178 01179 XMLEntityResolver* m_xmlEntityResolver; 01180 01181 ErrorHandler* m_errorHandler; 01182 01183 XalanDOMString m_externalSchemaLocation; 01184 01185 XalanDOMString m_externalNoNamespaceSchemaLocation; 01186 01187 ProblemListener* m_problemListener; 01188 01189 StreamType* m_errorStream; 01190 01191 StreamType* m_warningStream; 01192 01193 XalanDOMString m_outputEncoding; 01194 01195 bool m_poolAllTextNodes; 01196 01197 XObjectFactoryDefault* m_topXObjectFactory; 01198 01199 // This should always be the latest data member!!! 01200 StylesheetExecutionContextDefault* m_stylesheetExecutionContext; 01201 01202 static const XSLTInputSource* s_emptyInputSource; 01203 01204 static const XSLTInit* s_xsltInit; 01205 }; 01206 01207 01208 01209 XALAN_CPP_NAMESPACE_END 01210 01211 01212 01213 #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.11 |
|