Xalan-C++ API Reference  1.12.0
XSLTProcessor.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #if !defined(XALAN_XSLTPROCESSOR_HEADER_GUARD)
20 #define XALAN_XSLTPROCESSOR_HEADER_GUARD
21 
22 
23 
24 // Base include file. Must be first.
25 #include "XSLTDefinitions.hpp"
26 
27 
28 
29 #include <cstddef>
30 
31 
32 
34 
35 
36 
37 namespace XERCES_CPP_NAMESPACE
38 {
39  class Locator;
40 }
41 
42 
43 
44 namespace XALAN_CPP_NAMESPACE {
45 
46 
47 
48 using xercesc::Locator;;
49 
50 
51 
52 class ElemTemplateElement;
53 class FormatterListener;
54 class GenerateEvent;
55 class NodeRefListBase;
56 class PrefixResolver;
57 class PrintWriter;
58 class SelectionEvent;
59 class StylesheetConstructionContext;
60 class StylesheetExecutionContext;
61 class StylesheetRoot;
62 class TraceListener;
63 class TracerEvent;
64 class XalanDOMString;
65 class XalanDocument;
66 class XalanElement;
67 class XalanNode;
68 class XMLParserLiaison;
69 class XObject;
70 class XObjectPtr;
71 class XPath;
72 class XPathExecutionContext;
73 class XSLTInputSource;
74 class XSLTResultTarget;
75 
76 
77 
78 /**
79  * This is an interface for an XSLT Processor engine. It's the responsibility
80  * of the implementation of the XSLTProcessor interface, collaborating with a
81  * XMLParserLiaison, the DOM, and the XPath engine, to transform a source tree
82  * of nodes into a result tree according to instructions and templates
83  * specified by a stylesheet tree. The methods process(...) are
84  * the primary public entry points.
85  *
86  * If you reuse the processor instance, you should call reset() between calls.
87  */
89 {
90 public:
91 
92  typedef XalanSize_t size_type;
93 
94  XSLTProcessor();
95 
96  virtual
97  ~XSLTProcessor();
98 
99 
100  // These interfaces are inherited from ProblemListenerBase.
101 
102  virtual void
103  problem(
104  eSource source,
105  eClassification classification,
106  const XalanDOMString& msg,
107  const Locator* locator,
108  const XalanNode* sourceNode) = 0;
109 
110  virtual void
111  problem(
112  eSource source,
113  eClassification classification,
114  const XalanDOMString& msg,
115  const XalanNode* sourceNode) = 0;
116 
117  // These interfaces are new to XSLTProcessor
118  /**
119  * Transform the source tree to the output in the given result tree target.
120  * The processor will process the input source, the stylesheet source,
121  * and transform to the output target.
122  *
123  * @param inputSource input source
124  * @param stylesheetSource stylesheet source
125  * @param outputTarget output source tree
126  * @param constructionContext context for construction of objects
127  * @param executionContext current execution context
128  * @exception XSLProcessorException
129  */
130  virtual void
131  process(
132  const XSLTInputSource& inputSource,
133  const XSLTInputSource& stylesheetSource,
134  XSLTResultTarget& outputTarget,
135  StylesheetConstructionContext& constructionContext,
136  StylesheetExecutionContext& executionContext) = 0;
137 
138  /**
139  * Transform the source tree to the output in the given result tree target.
140  * This function does not create a stylesheet tree, it assumes the
141  * provided StylesheetExecutionContext has the stylesheet tree to use. This
142  * is set by calling StylesheetExecutionContext::setStylesheetRoot().
143  *
144  * @param inputSource input source
145  * @param outputTarget output source tree
146  * @param executionContext current execution context
147  * @exception XSLProcessorException
148  */
149  virtual void
150  process(
151  const XSLTInputSource& inputSource,
152  XSLTResultTarget& outputTarget,
153  StylesheetExecutionContext& executionContext) = 0;
154 
155  /**
156  * Given a stylesheet input source, compile the stylesheet into an internal
157  * representation.
158  *
159  * @param stylesheetSource input source for the stylesheet
160  * @param constructionContext context for construction of objects
161  * @return pointer to the compiled stylesheet object
162  * @exception XSLProcessorException
163  */
164  virtual StylesheetRoot*
165  processStylesheet(
166  const XSLTInputSource& stylesheetSource,
167  StylesheetConstructionContext& constructionContext) = 0;
168 
169  /**
170  * Given a URI to an XSL stylesheet, compile the stylesheet into an internal
171  * representation.
172  *
173  * @param xmldocURLString URI to the input XML document
174  * @param constructionContext context for construction of objects
175  * @return pointer to compiled stylesheet object
176  * @exception XSLProcessorException
177  */
178  virtual StylesheetRoot*
179  processStylesheet(
180  const XalanDOMString& xsldocURLString,
181  StylesheetConstructionContext& constructionContext) = 0;
182 
183  /**
184  * Reset the state. This needs to be called after a process() call
185  * is invoked, if the processor is to be used again.
186  */
187  virtual void
188  reset() = 0;
189 
190  /**
191  * Given an input source, get the source tree.
192  *
193  * @param inputSource pointer to input source
194  * @return source tree
195  */
196  virtual XalanNode*
197  getSourceTreeFromInput(const XSLTInputSource& inputSource) = 0;
198 
199  /**
200  * Retrieve the root stylesheet.
201  *
202  * @return pointer to root stylesheet
203  */
204  virtual const StylesheetRoot*
205  getStylesheetRoot() const = 0;
206 
207  /**
208  * Set the root stylesheet.
209  *
210  * @param theStylesheet pointer to new root stylesheet
211  */
212  virtual void
213  setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
214 
215  /**
216  * Set the execution context. Must be set if after calling
217  * setStylesheetRoot.
218  *
219  * @param theExecutionContext pointer to new execution context.
220  */
221  virtual void
222  setExecutionContext(StylesheetExecutionContext* theExecutionContext) = 0;
223 
224  /**
225  * Resolve the params that were pushed by the caller.
226  */
227  virtual void
228  resolveTopLevelParams(StylesheetExecutionContext& executionContext) = 0;
229 
230  /**
231  * Get the XML Parser Liaison that this processor uses.
232  *
233  * @return XML parser liaison object
234  */
235  virtual XMLParserLiaison&
236  getXMLParserLiaison() const = 0;
237 
238 
239  /**
240  * Generate a random namespace prefix guaranteed to be unique.
241  *
242  * @param theValue A string for returning the new prefix
243  */
244  virtual void
245  getUniqueNamespaceValue(XalanDOMString& theValue) = 0;
246 
247  /**
248  * Set a top-level parameter, which the stylesheet can access
249  * with a top-level xsl:param. Top-level params are "sticky,"
250  * and must be removed with a call to clearStylesheetParams().
251  *
252  * @param key name of the parameter
253  * @param value XObject value for parameter
254  */
255  virtual void
256  setStylesheetParam(
257  const XalanDOMString& key,
258  XObjectPtr value) = 0;
259 
260  /**
261  * Set a top-level parameter, which the stylesheet can access
262  * with a top-level xsl:param. Top-level params are "sticky,"
263  * and must be removed with a call to clearStylesheetParams().
264  *
265  * @param key name of the param
266  * @param expression expression that will be evaluated
267  */
268  virtual void
269  setStylesheetParam(
270  const XalanDOMString& key,
271  const XalanDOMString& expression) = 0;
272 
273  /**
274  * Clear any stylesheet params.
275  */
276  virtual void
277  clearStylesheetParams() = 0;
278 
279  /**
280  * Get the current formatter listener.
281  *
282  * @return pointer to formatter listener
283  */
284  virtual FormatterListener*
285  getFormatterListener() const = 0;
286 
287  /**
288  * Set the current formatter listener.
289  *
290  * @param flistener pointer to new formatter listener
291  */
292  virtual void
293  setFormatterListener(FormatterListener* flistener) = 0;
294 
295  /**
296  * Determine the number of trace listeners.
297  *
298  * @return number of listeners
299  */
300  virtual size_type
301  getTraceListeners() const = 0;
302 
303  /**
304  * Add a trace listener for the purposes of debugging and diagnosis.
305  *
306  * @param tl pointer to listener to add
307  */
308  virtual void
309  addTraceListener(TraceListener* tl) = 0;
310 
311  /**
312  * Remove a trace listener.
313  *
314  * @param tl Trace listener to be removed.
315  */
316  virtual void
317  removeTraceListener(TraceListener* tl) = 0;
318 
319  /**
320  * Fire a generate event.
321  *
322  * @param ge generate event to fire
323  */
324  virtual void
325  fireGenerateEvent(const GenerateEvent& ge) = 0;
326 
327  /**
328  * Fire a trace event.
329  *
330  * @param te trace event to fire
331  */
332  virtual void
333  fireTraceEvent(const TracerEvent& te) = 0;
334 
335  /**
336  * Fire a selection event.
337  *
338  * @param se selection event to fire
339  */
340  virtual void
341  fireSelectEvent(const SelectionEvent& se) = 0;
342 
343  /**
344  * If this is set to true, simple traces of template calls are made.
345  *
346  * @return true if traces made
347  */
348  virtual bool
349  getTraceSelects() const = 0;
350 
351  /**
352  * Compose a diagnostic trace of the current selection
353  *
354  * @param executionContext The current execution context
355  * @param theStylesheetElement The executing stylesheet element
356  * @param nl The list of selected nodes
357  * @param xpath A pointer to the XPath which generated the list of nodes, if any.
358  */
359  virtual void
360  traceSelect(
361  StylesheetExecutionContext& executionContext,
362  const ElemTemplateElement& theStylesheetElement,
363  const NodeRefListBase& nl,
364  const XPath* xpath) const = 0;
365 
366  /**
367  * If the quietConflictWarnings property is set to
368  * true, warnings about pattern conflicts won't be
369  * printed to the diagnostics stream.
370  * True by default.
371  *
372  * @param b true if conflict warnings should be suppressed.
373  */
374  virtual void
375  setQuietConflictWarnings(bool b) = 0;
376 
377  /**
378  * If this is set, diagnostics will be
379  * written to the m_diagnosticsPrintWriter stream. If
380  * the value is null, then diagnostics will be turned
381  * off.
382  *
383  * @param pw pointer to print writer
384  */
385  virtual void
386  setDiagnosticsOutput(PrintWriter* pw) = 0;
387 };
388 
389 
390 
391 }
392 
393 
394 
395 #endif // XALAN_XSLTPROCESSOR_HEADER_GUARD
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::StylesheetExecutionContext
Definition: StylesheetExecutionContext.hpp:106
xalanc::XalanNode
Definition: XalanNode.hpp:38
xalanc::XPath
Definition: XPath.hpp:67
XALAN_XSLT_EXPORT
#define XALAN_XSLT_EXPORT
Definition: XSLTDefinitions.hpp:27
xalanc::TraceListener
Definition: TraceListener.hpp:36
xalanc::ElemTemplateElement
Definition: ElemTemplateElement.hpp:79
xalanc::XSLTProcessor::size_type
XalanSize_t size_type
Definition: XSLTProcessor.hpp:92
xalanc::XSLTResultTarget
Definition: XSLTResultTarget.hpp:45
xalanc::XObjectPtr
Class to hold XObjectPtr return types.
Definition: XObject.hpp:883
xalanc::SelectionEvent
Definition: SelectionEvent.hpp:47
xalanc::XSLTProcessor
This is an interface for an XSLT Processor engine.
Definition: XSLTProcessor.hpp:88
xalanc::ProblemListenerBase::eSource
eSource
Definition: ProblemListenerBase.hpp:62
xalanc::XSLTInputSource
Definition: XSLTInputSource.hpp:62
xalanc::StylesheetConstructionContext
Definition: StylesheetConstructionContext.hpp:83
xalanc::PrintWriter
Definition: PrintWriter.hpp:37
xalanc::ProblemListenerBase::eClassification
eClassification
Definition: ProblemListenerBase.hpp:75
xalanc::XMLParserLiaison
Definition: XMLParserLiaison.hpp:68
xalanc::TracerEvent
This is the parent class of events generated for tracing the progress of the XSL processor.
Definition: TracerEvent.hpp:49
xalanc::StylesheetRoot
This acts as the stylesheet root of the stylesheet tree, and holds values that are shared by all styl...
Definition: StylesheetRoot.hpp:63
XSLTDefinitions.hpp
xalanc::FormatterListener
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:56
xalanc::NodeRefListBase
Local implementation of NodeRefList.
Definition: NodeRefListBase.hpp:44
xalanc::GenerateEvent
This is the class for events generated by the XSL processor after it generates a new node in the resu...
Definition: GenerateEvent.hpp:55
xalanc::ProblemListenerBase
This is the abstract class that is used when reporting a problem some kind, that requires a message,...
Definition: ProblemListenerBase.hpp:56
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
ProblemListenerBase.hpp