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(XALAN_XSLTPROCESSOR_HEADER_GUARD) 00020 #define XALAN_XSLTPROCESSOR_HEADER_GUARD 00021 00022 00023 00024 // Base include file. Must be first. 00025 #include "XSLTDefinitions.hpp" 00026 00027 00028 00029 #include <cstddef> 00030 00031 00032 00033 #include "xalanc/PlatformSupport/ProblemListenerBase.hpp" 00034 00035 00036 00037 XALAN_DECLARE_XERCES_CLASS(Locator) 00038 00039 00040 00041 XALAN_CPP_NAMESPACE_BEGIN 00042 00043 00044 00045 XALAN_USING_XERCES(Locator); 00046 00047 00048 00049 class ElemTemplateElement; 00050 class FormatterListener; 00051 class GenerateEvent; 00052 class NodeRefListBase; 00053 class PrefixResolver; 00054 class PrintWriter; 00055 class SelectionEvent; 00056 class StylesheetConstructionContext; 00057 class StylesheetExecutionContext; 00058 class StylesheetRoot; 00059 class TraceListener; 00060 class TracerEvent; 00061 class XalanDOMString; 00062 class XalanDocument; 00063 class XalanElement; 00064 class XalanNode; 00065 class XMLParserLiaison; 00066 class XObject; 00067 class XObjectPtr; 00068 class XPath; 00069 class XPathExecutionContext; 00070 class XSLTInputSource; 00071 class XSLTResultTarget; 00072 00073 00074 00075 /** 00076 * This is an interface for an XSLT Processor engine. It's the responsibility 00077 * of the implementation of the XSLTProcessor interface, collaborating with a 00078 * XMLParserLiaison, the DOM, and the XPath engine, to transform a source tree 00079 * of nodes into a result tree according to instructions and templates 00080 * specified by a stylesheet tree. The methods process(...) are 00081 * the primary public entry points. 00082 * 00083 * If you reuse the processor instance, you should call reset() between calls. 00084 */ 00085 class XALAN_XSLT_EXPORT XSLTProcessor : public ProblemListenerBase 00086 { 00087 public: 00088 00089 typedef XalanSize_t size_type; 00090 00091 XSLTProcessor(); 00092 00093 virtual 00094 ~XSLTProcessor(); 00095 00096 00097 // These interfaces are inherited from ProblemListenerBase. 00098 00099 virtual void 00100 problem( 00101 eSource source, 00102 eClassification classification, 00103 const XalanDOMString& msg, 00104 const Locator* locator, 00105 const XalanNode* sourceNode) = 0; 00106 00107 virtual void 00108 problem( 00109 eSource source, 00110 eClassification classification, 00111 const XalanDOMString& msg, 00112 const XalanNode* sourceNode) = 0; 00113 00114 // These interfaces are new to XSLTProcessor 00115 /** 00116 * Transform the source tree to the output in the given result tree target. 00117 * The processor will process the input source, the stylesheet source, 00118 * and transform to the output target. 00119 * 00120 * @param inputSource input source 00121 * @param stylesheetSource stylesheet source 00122 * @param outputTarget output source tree 00123 * @param constructionContext context for construction of objects 00124 * @param executionContext current execution context 00125 * @exception XSLProcessorException 00126 */ 00127 virtual void 00128 process( 00129 const XSLTInputSource& inputSource, 00130 const XSLTInputSource& stylesheetSource, 00131 XSLTResultTarget& outputTarget, 00132 StylesheetConstructionContext& constructionContext, 00133 StylesheetExecutionContext& executionContext) = 0; 00134 00135 /** 00136 * Transform the source tree to the output in the given result tree target. 00137 * This function does not create a stylesheet tree, it assumes the 00138 * provided StylesheetExecutionContext has the stylesheet tree to use. This 00139 * is set by calling StylesheetExecutionContext::setStylesheetRoot(). 00140 * 00141 * @param inputSource input source 00142 * @param outputTarget output source tree 00143 * @param executionContext current execution context 00144 * @exception XSLProcessorException 00145 */ 00146 virtual void 00147 process( 00148 const XSLTInputSource& inputSource, 00149 XSLTResultTarget& outputTarget, 00150 StylesheetExecutionContext& executionContext) = 0; 00151 00152 /** 00153 * Given a stylesheet input source, compile the stylesheet into an internal 00154 * representation. 00155 * 00156 * @param stylesheetSource input source for the stylesheet 00157 * @param constructionContext context for construction of objects 00158 * @return pointer to the compiled stylesheet object 00159 * @exception XSLProcessorException 00160 */ 00161 virtual StylesheetRoot* 00162 processStylesheet( 00163 const XSLTInputSource& stylesheetSource, 00164 StylesheetConstructionContext& constructionContext) = 0; 00165 00166 /** 00167 * Given a URI to an XSL stylesheet, compile the stylesheet into an internal 00168 * representation. 00169 * 00170 * @param xmldocURLString URI to the input XML document 00171 * @param constructionContext context for construction of objects 00172 * @return pointer to compiled stylesheet object 00173 * @exception XSLProcessorException 00174 */ 00175 virtual StylesheetRoot* 00176 processStylesheet( 00177 const XalanDOMString& xsldocURLString, 00178 StylesheetConstructionContext& constructionContext) = 0; 00179 00180 /** 00181 * Reset the state. This needs to be called after a process() call 00182 * is invoked, if the processor is to be used again. 00183 */ 00184 virtual void 00185 reset() = 0; 00186 00187 /** 00188 * Given an input source, get the source tree. 00189 * 00190 * @param inputSource pointer to input source 00191 * @return source tree 00192 */ 00193 virtual XalanNode* 00194 getSourceTreeFromInput(const XSLTInputSource& inputSource) = 0; 00195 00196 /** 00197 * Retrieve the root stylesheet. 00198 * 00199 * @return pointer to root stylesheet 00200 */ 00201 virtual const StylesheetRoot* 00202 getStylesheetRoot() const = 0; 00203 00204 /** 00205 * Set the root stylesheet. 00206 * 00207 * @param theStylesheet pointer to new root stylesheet 00208 */ 00209 virtual void 00210 setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0; 00211 00212 /** 00213 * Set the execution context. Must be set if after calling 00214 * setStylesheetRoot. 00215 * 00216 * @param theExecutionContext pointer to new execution context. 00217 */ 00218 virtual void 00219 setExecutionContext(StylesheetExecutionContext* theExecutionContext) = 0; 00220 00221 /** 00222 * Resolve the params that were pushed by the caller. 00223 */ 00224 virtual void 00225 resolveTopLevelParams(StylesheetExecutionContext& executionContext) = 0; 00226 00227 /** 00228 * Get the XML Parser Liaison that this processor uses. 00229 * 00230 * @return XML parser liaison object 00231 */ 00232 virtual XMLParserLiaison& 00233 getXMLParserLiaison() const = 0; 00234 00235 00236 /** 00237 * Generate a random namespace prefix guaranteed to be unique. 00238 * 00239 * @param theValue A string for returning the new prefix 00240 */ 00241 virtual void 00242 getUniqueNamespaceValue(XalanDOMString& theValue) = 0; 00243 00244 /** 00245 * Set a top-level parameter, which the stylesheet can access 00246 * with a top-level xsl:param. Top-level params are "sticky," 00247 * and must be removed with a call to clearStylesheetParams(). 00248 * 00249 * @param key name of the parameter 00250 * @param value XObject value for parameter 00251 */ 00252 virtual void 00253 setStylesheetParam( 00254 const XalanDOMString& key, 00255 XObjectPtr value) = 0; 00256 00257 /** 00258 * Set a top-level parameter, which the stylesheet can access 00259 * with a top-level xsl:param. Top-level params are "sticky," 00260 * and must be removed with a call to clearStylesheetParams(). 00261 * 00262 * @param key name of the param 00263 * @param expression expression that will be evaluated 00264 */ 00265 virtual void 00266 setStylesheetParam( 00267 const XalanDOMString& key, 00268 const XalanDOMString& expression) = 0; 00269 00270 /** 00271 * Clear any stylesheet params. 00272 */ 00273 virtual void 00274 clearStylesheetParams() = 0; 00275 00276 /** 00277 * Get the current formatter listener. 00278 * 00279 * @return pointer to formatter listener 00280 */ 00281 virtual FormatterListener* 00282 getFormatterListener() const = 0; 00283 00284 /** 00285 * Set the current formatter listener. 00286 * 00287 * @param flistener pointer to new formatter listener 00288 */ 00289 virtual void 00290 setFormatterListener(FormatterListener* flistener) = 0; 00291 00292 /** 00293 * Determine the number of trace listeners. 00294 * 00295 * @return number of listeners 00296 */ 00297 virtual size_type 00298 getTraceListeners() const = 0; 00299 00300 /** 00301 * Add a trace listener for the purposes of debugging and diagnosis. 00302 * 00303 * @param tl pointer to listener to add 00304 */ 00305 virtual void 00306 addTraceListener(TraceListener* tl) = 0; 00307 00308 /** 00309 * Remove a trace listener. 00310 * 00311 * @param tl Trace listener to be removed. 00312 */ 00313 virtual void 00314 removeTraceListener(TraceListener* tl) = 0; 00315 00316 /** 00317 * Fire a generate event. 00318 * 00319 * @param ge generate event to fire 00320 */ 00321 virtual void 00322 fireGenerateEvent(const GenerateEvent& ge) = 0; 00323 00324 /** 00325 * Fire a trace event. 00326 * 00327 * @param te trace event to fire 00328 */ 00329 virtual void 00330 fireTraceEvent(const TracerEvent& te) = 0; 00331 00332 /** 00333 * Fire a selection event. 00334 * 00335 * @param se selection event to fire 00336 */ 00337 virtual void 00338 fireSelectEvent(const SelectionEvent& se) = 0; 00339 00340 /** 00341 * If this is set to true, simple traces of template calls are made. 00342 * 00343 * @return true if traces made 00344 */ 00345 virtual bool 00346 getTraceSelects() const = 0; 00347 00348 /** 00349 * Compose a diagnostic trace of the current selection 00350 * 00351 * @param executionContext The current execution context 00352 * @param theStylesheetElement The executing stylesheet element 00353 * @param nl The list of selected nodes 00354 * @param xpath A pointer to the XPath which generated the list of nodes, if any. 00355 */ 00356 virtual void 00357 traceSelect( 00358 StylesheetExecutionContext& executionContext, 00359 const ElemTemplateElement& theStylesheetElement, 00360 const NodeRefListBase& nl, 00361 const XPath* xpath) const = 0; 00362 00363 /** 00364 * If the quietConflictWarnings property is set to 00365 * true, warnings about pattern conflicts won't be 00366 * printed to the diagnostics stream. 00367 * True by default. 00368 * 00369 * @param b true if conflict warnings should be suppressed. 00370 */ 00371 virtual void 00372 setQuietConflictWarnings(bool b) = 0; 00373 00374 /** 00375 * If this is set, diagnostics will be 00376 * written to the m_diagnosticsPrintWriter stream. If 00377 * the value is null, then diagnostics will be turned 00378 * off. 00379 * 00380 * @param pw pointer to print writer 00381 */ 00382 virtual void 00383 setDiagnosticsOutput(PrintWriter* pw) = 0; 00384 }; 00385 00386 00387 00388 XALAN_CPP_NAMESPACE_END 00389 00390 00391 00392 #endif // XALAN_XSLTPROCESSOR_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 |
|