Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo