Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


XMLParserLiaison.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 #if !defined(XMLPARSERLIAISON_HEADER_GUARD_1357924680)
19 #define XMLPARSERLIAISON_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 XALAN_DECLARE_XERCES_CLASS(DocumentHandler)
33 XALAN_DECLARE_XERCES_CLASS(EntityResolver)
34 XALAN_DECLARE_XERCES_CLASS(ErrorHandler)
35 XALAN_DECLARE_XERCES_CLASS(InputSource)
36 XALAN_DECLARE_XERCES_CLASS(XMLEntityResolver)
37 
38 
39 
40 XALAN_CPP_NAMESPACE_BEGIN
41 
42 
43 
44 typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler DocumentHandlerType;
45 typedef XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType;
46 typedef XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType;
47 typedef XERCES_CPP_NAMESPACE_QUALIFIER InputSource InputSourceType;
48 
49 XALAN_USING_XERCES(DocumentHandler)
50 XALAN_USING_XERCES(EntityResolver)
51 XALAN_USING_XERCES(ErrorHandler)
52 XALAN_USING_XERCES(InputSource)
53 XALAN_USING_XERCES(XMLEntityResolver)
54 
55 
56 
57 class ExecutionContext;
58 class FormatterListener;
59 class XalanAttr;
60 class XalanDocument;
61 class XalanElement;
62 
63 
64 
66 {
67 
68 public:
69 
71 
72  virtual
74 
75 
76  // These interfaces are new to XMLParserLiaison
77 
78  /**
79  * Reset the instance, freeing any XalanDocument instances created
80  * through parseXMLStream().
81  */
82  virtual void
83  reset() = 0;
84 
85  /**
86  * Get a pointer to the current ExecutionContext instance, which
87  * may be null.
88  *
89  * @return A pointer to the current ExecutionContext, if any.
90  */
91  virtual ExecutionContext*
92  getExecutionContext() const = 0;
93 
94  /**
95  * Get a reference to the current MemoryManager instance.
96  *
97  * @return A pointer to the current ExecutionContext, if any.
98  */
99  virtual MemoryManager&
100  getMemoryManager() = 0;
101 
102  /**
103  * Set the current ExecutionContext instance.
104  *
105  * @parameter theContext A reference to the new ExecutionContext instance.
106  */
107  virtual void
108  setExecutionContext(ExecutionContext& theContext) = 0;
109 
110  /**
111  * Parse the text pointed at by the reader as XML, and return a DOM
112  * Document interface. It is recommended that you pass in some sort of
113  * recognizable name, such as the filename or URI, with which the reader
114  * can be recognized if the parse fails.
115  *
116  * The liaison owns the XalanDocument instance, and will delete it when
117  * asked (see DestroyDocument()), or when the liaison is reset, or goes
118  * out of scope.
119  *
120  * This function is not reentrant, so you cannot call it again until
121  * the current call exits.
122  *
123  * @param reader stream that should hold valid XML
124  * @param identifier used for diagnostic purposes only, some sort of
125  * identification for error reporting, default an empty
126  * string
127  * @return DOM document created
128  */
129  virtual XalanDocument*
130  parseXMLStream(
131  const InputSource& inputSource,
132  const XalanDOMString& identifier) = 0;
133 
134  /**
135  * Parse the text pointed at by the reader as XML. It is recommended that
136  * you pass in some sort of recognizable name, such as the filename or URI,
137  * with which the reader can be recognized if the parse fails.
138  *
139  * This function is reentrant, so you can call it again before any
140  * other call exits. However, it is not thread-safe.
141  *
142  * @param inputSource input source that should hold valid XML
143  * @param handler instance of a DocumentHandler
144  * @param identifier used for diagnostic purposes only, some sort of
145  * identification for error reporting, default an
146  * empty string
147  */
148  virtual void
149  parseXMLStream(
150  const InputSource& inputSource,
151  DocumentHandler& handler,
152  const XalanDOMString& identifier) = 0;
153 
154  /**
155  * Destroy the supplied XalanDocument instance. It must be an instance that
156  * was created by a previous call to parseXMLStream().
157  *
158  * @param theDocument The XalanDocument instance to destroy.
159  */
160  virtual void
161  destroyDocument(XalanDocument* theDocument) = 0;
162 
163  /**
164  * Get the amount to indent when indent-result="yes".
165  *
166  * @deprecated
167  *
168  * @return number of characters to indent
169  */
170  virtual int
171  getIndent() const = 0;
172 
173  /**
174  * Set the amount to indent when indent-result="yes".
175  *
176  * @deprecated
177  *
178  * @param i number of characters to indent
179  */
180  virtual void
181  setIndent(int i) = 0;
182 
183  /**
184  * Get whether or not validation will be performed. Validation is off by
185  * default.
186  *
187  * @return true to perform validation
188  */
189  virtual bool
190  getUseValidation() const = 0;
191 
192  /**
193  * If set to true, validation will be performed. Validation is off by
194  * default.
195  *
196  * @param b true to perform validation
197  */
198  virtual void
199  setUseValidation(bool b) = 0;
200 
201  /**
202  * Return a string suitable for telling the user what parser is being used.
203  *
204  * @return string describing parser
205  */
206  virtual const XalanDOMString&
207  getParserDescription(XalanDOMString& theResult) const = 0;
208 
209  /**
210  * This method returns the installed EntityResolver.
211  *
212  * @return The pointer to the installed EntityResolver object.
213  */
214  virtual EntityResolver*
215  getEntityResolver() const = 0;
216 
217  /**
218  * This method installs the user-specified EntityResolver on the
219  * parser. It allows applications to trap and redirect calls to
220  * external entities.
221  *
222  * A call to setEntityResolver with a non-null pointer will
223  * uninstall any XMLEntityResolver previously installed.
224  *
225  * @param handler A pointer to the EntityResolver to be called
226  * when the parser encounters references to
227  * external entities.
228  */
229  virtual void
230  setEntityResolver(EntityResolver* resolver) = 0;
231 
232  /**
233  * This method returns the installed XMLEntityResolver.
234  *
235  * @return The pointer to the installed XMLEntityResolver object.
236  */
237  virtual XMLEntityResolver*
238  getXMLEntityResolver() const = 0;
239 
240  /**
241  * This method installs the user-specified XMLEntityResolver on the
242  * parser. It allows applications to trap and redirect calls to
243  * external entities.
244  *
245  * A call to setXMLEntityResolver with a non-null pointer will
246  * uninstall any EntityResolver previously installed.
247  *
248  * @param handler A pointer to the entity resolver to be called
249  * when the parser encounters references to
250  * external entities.
251  */
252  virtual void
253  setXMLEntityResolver(XMLEntityResolver* resolver) = 0;
254 
255  /**
256  * This method returns the installed error handler.
257  *
258  * @return The pointer to the installed error handler object.
259  */
260  virtual ErrorHandler*
261  getErrorHandler() const = 0;
262 
263  /**
264  * This method installs the user-specified error handler.
265  *
266  * @param handler A pointer to the error handler to be called upon error.
267  */
268  virtual void
269  setErrorHandler(ErrorHandler* handler) = 0;
270 
271  // A utility class for classes to use.
273  {
274  public:
275 
277  XMLParserLiaison* theLiaison = 0,
278  ErrorHandler* theErrorHandler = 0) :
279  m_liaison(theLiaison),
280  m_errorHandler(theErrorHandler)
281  {
282  if (theLiaison != 0)
283  {
284  theLiaison->setErrorHandler(theErrorHandler);
285  }
286  }
287 
289  {
290  if (m_liaison != 0)
291  {
292  m_liaison->setErrorHandler(m_errorHandler);
293  }
294  }
295 
296  void
297  set(
298  XMLParserLiaison* theLiaison,
299  ErrorHandler* theErrorHandler)
300  {
301  m_liaison = theLiaison;
302 
303  m_errorHandler = theErrorHandler;
304 
305  if (theLiaison != 0)
306  {
307  theLiaison->setErrorHandler(theErrorHandler);
308  }
309  }
310 
311  private:
312 
313  XMLParserLiaison* m_liaison;
314 
315  ErrorHandler* m_errorHandler;
316  };
317 
318 protected:
319 
320  // A utility class for derived classes to use.
322  {
323  public:
324 
326  XMLParserLiaison& theLiaison,
327  XalanDocument* theDocument) :
328  m_liaison(theLiaison),
329  m_document(theDocument)
330  {
331  }
332 
334  {
335  if (m_document != 0)
336  {
337  m_liaison.destroyDocument(m_document);
338  }
339  }
340 
342  get() const
343  {
344  return m_document;
345  }
346 
349  {
350  XalanDocument* theDocument = m_document;
351 
352  m_document = 0;
353 
354  return theDocument;
355  }
356 
357  private:
358 
359  XMLParserLiaison& m_liaison;
360 
361  XalanDocument* m_document;
362  };
363 
364 private:
365 
366  // Not implemented
368 
370  operator=(const XMLParserLiaison&);
371 };
372 
373 
374 
375 XALAN_CPP_NAMESPACE_END
376 
377 
378 
379 #endif // XMLPARSERLIAISON_HEADER_GUARD_1357924680
XERCES_CPP_NAMESPACE_QUALIFIER InputSource InputSourceType
A SAX-based formatter interface for the XSL processor.
#define XALAN_XMLSUPPORT_EXPORT
virtual void setErrorHandler(ErrorHandler *handler)=0
This method installs the user-specified error handler.
EnsureResetErrorHandler(XMLParserLiaison *theLiaison=0, ErrorHandler *theErrorHandler=0)
XERCES_CPP_NAMESPACE_QUALIFIER ErrorHandler ErrorHandlerType
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
EnsureDestroyDocument(XMLParserLiaison &theLiaison, XalanDocument *theDocument)
XERCES_CPP_NAMESPACE_QUALIFIER EntityResolver EntityResolverType
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler DocumentHandlerType

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