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