1 | #ifndef DOMBuilder_HEADER_GUARD_
|
---|
2 | #define DOMBuilder_HEADER_GUARD_
|
---|
3 |
|
---|
4 | /*
|
---|
5 | * Copyright 2002,2004 The Apache Software Foundation.
|
---|
6 | *
|
---|
7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
8 | * you may not use this file except in compliance with the License.
|
---|
9 | * You may obtain a copy of the License at
|
---|
10 | *
|
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
12 | *
|
---|
13 | * Unless required by applicable law or agreed to in writing, software
|
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
16 | * See the License for the specific language governing permissions and
|
---|
17 | * limitations under the License.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /*
|
---|
21 | * $Id: DOMBuilder.hpp,v 1.12 2004/09/08 13:55:38 peiyongz Exp $
|
---|
22 | *
|
---|
23 | */
|
---|
24 |
|
---|
25 |
|
---|
26 | #include <xercesc/util/XercesDefs.hpp>
|
---|
27 |
|
---|
28 | XERCES_CPP_NAMESPACE_BEGIN
|
---|
29 |
|
---|
30 |
|
---|
31 | class DOMErrorHandler;
|
---|
32 | class DOMEntityResolver;
|
---|
33 | class DOMInputSource;
|
---|
34 | class DOMBuilderFilter;
|
---|
35 | class DOMNode;
|
---|
36 | class DOMDocument;
|
---|
37 | class Grammar;
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * DOMBuilder provides an API for parsing XML documents and building the
|
---|
41 | * corresponding DOM document tree. A DOMBuilder instance is obtained from
|
---|
42 | * the DOMImplementationLS interface by invoking its createDOMBuilder method.
|
---|
43 | * This implementation also allows the applications to install an error and
|
---|
44 | * an entity handler (useful extensions to the DOM specification).
|
---|
45 | *
|
---|
46 | * @since DOM Level 3
|
---|
47 | *
|
---|
48 | */
|
---|
49 | class CDOM_EXPORT DOMBuilder
|
---|
50 | {
|
---|
51 | protected :
|
---|
52 | // -----------------------------------------------------------------------
|
---|
53 | // Hidden constructors
|
---|
54 | // -----------------------------------------------------------------------
|
---|
55 | /** @name Hidden constructors */
|
---|
56 | //@{
|
---|
57 | DOMBuilder() {};
|
---|
58 | //@}
|
---|
59 |
|
---|
60 | private:
|
---|
61 | // -----------------------------------------------------------------------
|
---|
62 | // Unimplemented constructors and operators
|
---|
63 | // -----------------------------------------------------------------------
|
---|
64 | /** @name Unimplemented constructors and operators */
|
---|
65 | //@{
|
---|
66 | DOMBuilder(const DOMBuilder &);
|
---|
67 | DOMBuilder & operator = (const DOMBuilder &);
|
---|
68 | //@}
|
---|
69 |
|
---|
70 | public:
|
---|
71 | // -----------------------------------------------------------------------
|
---|
72 | // All constructors are hidden, just the destructor is available
|
---|
73 | // -----------------------------------------------------------------------
|
---|
74 | /** @name Destructor */
|
---|
75 | //@{
|
---|
76 | /**
|
---|
77 | * Destructor
|
---|
78 | *
|
---|
79 | */
|
---|
80 | virtual ~DOMBuilder() {};
|
---|
81 | //@}
|
---|
82 |
|
---|
83 | // -----------------------------------------------------------------------
|
---|
84 | // Class types
|
---|
85 | // -----------------------------------------------------------------------
|
---|
86 | /** @name Public Constants */
|
---|
87 | //@{
|
---|
88 | /**
|
---|
89 | * Action types for use in parseWithContext.
|
---|
90 | *
|
---|
91 | * <p> <code>ACTION_REPLACE</code>:
|
---|
92 | * Replace the context node with the result of parsing the input source.
|
---|
93 | * For this action to work the context node must be an
|
---|
94 | * <code>DOMElement</code>, <code>DOMText</code>, <code>DOMCDATASection</code>,
|
---|
95 | * <code>DOMComment</code>, <code>DOMProcessingInstruction</code>, or
|
---|
96 | * <code>DOMEntityReference</code> node.</p>
|
---|
97 | *
|
---|
98 | * <p> <code>ACTION_APPEND</code>:
|
---|
99 | * Append the result of parsing the input source to the context node. For
|
---|
100 | * this action to work, the context node must be an <code>DOMElement</code>.</p>
|
---|
101 | *
|
---|
102 | * <p> <code>ACTION_INSERT_AFTER</code>:
|
---|
103 | * Insert the result of parsing the input source after the context node.
|
---|
104 | * For this action to work the context nodes parent must be an
|
---|
105 | * <code>DOMElement</code>.</p>
|
---|
106 | *
|
---|
107 | * <p> <code>ACTION_INSERT_BEFORE</code>:
|
---|
108 | * Insert the result of parsing the input source before the context node.
|
---|
109 | * For this action to work the context nodes parent must be an
|
---|
110 | * <code>DOMElement</code>.</p>
|
---|
111 | *
|
---|
112 | * @see parseWithContext(...)
|
---|
113 | * @since DOM Level 3
|
---|
114 | */
|
---|
115 | enum ActionType
|
---|
116 | {
|
---|
117 | ACTION_REPLACE = 1,
|
---|
118 | ACTION_APPEND_AS_CHILDREN = 2,
|
---|
119 | ACTION_INSERT_AFTER = 3,
|
---|
120 | ACTION_INSERT_BEFORE = 4
|
---|
121 | };
|
---|
122 | //@}
|
---|
123 |
|
---|
124 | // -----------------------------------------------------------------------
|
---|
125 | // Virtual DOMBuilder interface
|
---|
126 | // -----------------------------------------------------------------------
|
---|
127 | /** @name Functions introduced in DOM Level 3 */
|
---|
128 | //@{
|
---|
129 |
|
---|
130 | // -----------------------------------------------------------------------
|
---|
131 | // Getter methods
|
---|
132 | // -----------------------------------------------------------------------
|
---|
133 |
|
---|
134 | /**
|
---|
135 | * Get a pointer to the error handler
|
---|
136 | *
|
---|
137 | * This method returns the installed error handler. If no handler
|
---|
138 | * has been installed, then it will be a zero pointer.
|
---|
139 | *
|
---|
140 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
141 | *
|
---|
142 | * @return The pointer to the installed error handler object.
|
---|
143 | * @since DOM Level 3
|
---|
144 | */
|
---|
145 | virtual DOMErrorHandler* getErrorHandler() = 0;
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * Get a const pointer to the error handler
|
---|
149 | *
|
---|
150 | * This method returns the installed error handler. If no handler
|
---|
151 | * has been installed, then it will be a zero pointer.
|
---|
152 | *
|
---|
153 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
154 | *
|
---|
155 | * @return A const pointer to the installed error handler object.
|
---|
156 | * @since DOM Level 3
|
---|
157 | */
|
---|
158 | virtual const DOMErrorHandler* getErrorHandler() const = 0;
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Get a pointer to the entity resolver
|
---|
162 | *
|
---|
163 | * This method returns the installed entity resolver. If no resolver
|
---|
164 | * has been installed, then it will be a zero pointer.
|
---|
165 | *
|
---|
166 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
167 | *
|
---|
168 | * @return The pointer to the installed entity resolver object.
|
---|
169 | * @since DOM Level 3
|
---|
170 | */
|
---|
171 | virtual DOMEntityResolver* getEntityResolver() = 0;
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * Get a const pointer to the entity resolver
|
---|
175 | *
|
---|
176 | * This method returns the installed entity resolver. If no resolver
|
---|
177 | * has been installed, then it will be a zero pointer.
|
---|
178 | *
|
---|
179 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
180 | *
|
---|
181 | * @return A const pointer to the installed entity resolver object.
|
---|
182 | * @since DOM Level 3
|
---|
183 | */
|
---|
184 | virtual const DOMEntityResolver* getEntityResolver() const = 0;
|
---|
185 |
|
---|
186 | /**
|
---|
187 | * Get a pointer to the application filter
|
---|
188 | *
|
---|
189 | * This method returns the installed application filter. If no filter
|
---|
190 | * has been installed, then it will be a zero pointer.
|
---|
191 | *
|
---|
192 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
193 | *
|
---|
194 | * @return The pointer to the installed application filter.
|
---|
195 | * @since DOM Level 3
|
---|
196 | */
|
---|
197 | virtual DOMBuilderFilter* getFilter() = 0;
|
---|
198 |
|
---|
199 | /**
|
---|
200 | * Get a const pointer to the application filter
|
---|
201 | *
|
---|
202 | * This method returns the installed application filter. If no filter
|
---|
203 | * has been installed, then it will be a zero pointer.
|
---|
204 | *
|
---|
205 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
206 | *
|
---|
207 | * @return A const pointer to the installed application filter
|
---|
208 | * @since DOM Level 3
|
---|
209 | */
|
---|
210 | virtual const DOMBuilderFilter* getFilter() const = 0;
|
---|
211 |
|
---|
212 | // -----------------------------------------------------------------------
|
---|
213 | // Setter methods
|
---|
214 | // -----------------------------------------------------------------------
|
---|
215 | /**
|
---|
216 | * Set the error handler
|
---|
217 | *
|
---|
218 | * This method allows applications to install their own error handler
|
---|
219 | * to trap error and warning messages.
|
---|
220 | *
|
---|
221 | * <i>Any previously set handler is merely dropped, since the parser
|
---|
222 | * does not own them.</i>
|
---|
223 | *
|
---|
224 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
225 | *
|
---|
226 | * @param handler A const pointer to the user supplied error
|
---|
227 | * handler.
|
---|
228 | *
|
---|
229 | * @see #getErrorHandler
|
---|
230 | * @since DOM Level 3
|
---|
231 | */
|
---|
232 | virtual void setErrorHandler(DOMErrorHandler* const handler) = 0;
|
---|
233 |
|
---|
234 | /**
|
---|
235 | * Set the entity resolver
|
---|
236 | *
|
---|
237 | * This method allows applications to install their own entity
|
---|
238 | * resolver. By installing an entity resolver, the applications
|
---|
239 | * can trap and potentially redirect references to external
|
---|
240 | * entities.
|
---|
241 | *
|
---|
242 | * <i>Any previously set resolver is merely dropped, since the parser
|
---|
243 | * does not own them.</i>
|
---|
244 | *
|
---|
245 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
246 | *
|
---|
247 | * @param handler A const pointer to the user supplied entity
|
---|
248 | * resolver.
|
---|
249 | *
|
---|
250 | * @see #getEntityResolver
|
---|
251 | * @since DOM Level 3
|
---|
252 | */
|
---|
253 | virtual void setEntityResolver(DOMEntityResolver* const handler) = 0;
|
---|
254 |
|
---|
255 | /**
|
---|
256 | * Set the application filter
|
---|
257 | *
|
---|
258 | * When the application provides a filter, the parser will call out to
|
---|
259 | * the filter at the completion of the construction of each Element node.
|
---|
260 | * The filter implementation can choose to remove the element from the
|
---|
261 | * document being constructed (unless the element is the document element)
|
---|
262 | * or to terminate the parse early. If the document is being validated
|
---|
263 | * when it's loaded the validation happens before the filter is called.
|
---|
264 | *
|
---|
265 | * <i>Any previously set filter is merely dropped, since the parser
|
---|
266 | * does not own them.</i>
|
---|
267 | *
|
---|
268 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
269 | *
|
---|
270 | * @param filter A const pointer to the user supplied application
|
---|
271 | * filter.
|
---|
272 | *
|
---|
273 | * @see #getFilter
|
---|
274 | * @since DOM Level 3
|
---|
275 | */
|
---|
276 | virtual void setFilter(DOMBuilderFilter* const filter) = 0;
|
---|
277 |
|
---|
278 | // -----------------------------------------------------------------------
|
---|
279 | // Feature methods
|
---|
280 | // -----------------------------------------------------------------------
|
---|
281 | /**
|
---|
282 | * Set the state of a feature
|
---|
283 | *
|
---|
284 | * It is possible for a DOMBuilder to recognize a feature name but to be
|
---|
285 | * unable to set its value.
|
---|
286 | *
|
---|
287 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
288 | *
|
---|
289 | * See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderFeatures for
|
---|
290 | * the list of supported features.
|
---|
291 | *
|
---|
292 | * @param name The feature name.
|
---|
293 | * @param state The requested state of the feature (true or false).
|
---|
294 | * @exception DOMException
|
---|
295 | * NOT_SUPPORTED_ERR: Raised when the DOMBuilder recognizes the
|
---|
296 | * feature name but cannot set the requested value.
|
---|
297 | * <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
|
---|
298 | * the feature name.
|
---|
299 | *
|
---|
300 | * @see #setFeature
|
---|
301 | * @see #canSetFeature
|
---|
302 | * @since DOM Level 3
|
---|
303 | */
|
---|
304 | virtual void setFeature(const XMLCh* const name, const bool state) = 0;
|
---|
305 |
|
---|
306 | /**
|
---|
307 | * Look up the value of a feature.
|
---|
308 | *
|
---|
309 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
310 | *
|
---|
311 | * @param name The feature name.
|
---|
312 | * @return The current state of the feature (true or false)
|
---|
313 | * @exception DOMException
|
---|
314 | * NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
|
---|
315 | * the feature name.
|
---|
316 | *
|
---|
317 | * @see #getFeature
|
---|
318 | * @see #canSetFeature
|
---|
319 | * @since DOM Level 3
|
---|
320 | */
|
---|
321 | virtual bool getFeature(const XMLCh* const name) const = 0;
|
---|
322 |
|
---|
323 | /**
|
---|
324 | * Query whether setting a feature to a specific value is supported.
|
---|
325 | *
|
---|
326 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
327 | *
|
---|
328 | * @param name The feature name.
|
---|
329 | * @param state The requested state of the feature (true or false).
|
---|
330 | * @return <code>true</code> if the feature could be successfully set
|
---|
331 | * to the specified value, or <code>false</code> if the feature
|
---|
332 | * is not recognized or the requested value is not supported. The
|
---|
333 | * value of the feature itself is not changed.
|
---|
334 | *
|
---|
335 | * @see #getFeature
|
---|
336 | * @see #setFeature
|
---|
337 | * @since DOM Level 3
|
---|
338 | */
|
---|
339 | virtual bool canSetFeature(const XMLCh* const name, const bool state) const = 0;
|
---|
340 |
|
---|
341 | // -----------------------------------------------------------------------
|
---|
342 | // Parsing methods
|
---|
343 | // -----------------------------------------------------------------------
|
---|
344 | /**
|
---|
345 | * Parse via an input source object
|
---|
346 | *
|
---|
347 | * This method invokes the parsing process on the XML file specified
|
---|
348 | * by the DOMInputSource parameter. This API is borrowed from the
|
---|
349 | * SAX Parser interface.
|
---|
350 | *
|
---|
351 | * The parser owns the returned DOMDocument. It will be deleted
|
---|
352 | * when the parser is released.
|
---|
353 | *
|
---|
354 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
355 | *
|
---|
356 | * @param source A const reference to the DOMInputSource object which
|
---|
357 | * points to the XML file to be parsed.
|
---|
358 | * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
|
---|
359 | * and populated DOMDocument is returned. If the DOMBuilder is
|
---|
360 | * asynchronous then <code>null</code> is returned since the
|
---|
361 | * document object is not yet parsed when this method returns.
|
---|
362 | * @exception SAXException Any SAX exception, possibly
|
---|
363 | * wrapping another exception.
|
---|
364 | * @exception XMLException An exception from the parser or client
|
---|
365 | * handler code.
|
---|
366 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
367 | *
|
---|
368 | * @see DOMInputSource#DOMInputSource
|
---|
369 | * @see #setEntityResolver
|
---|
370 | * @see #setErrorHandler
|
---|
371 | * @see resetDocumentPool
|
---|
372 | * @since DOM Level 3
|
---|
373 | */
|
---|
374 | virtual DOMDocument* parse(const DOMInputSource& source) = 0;
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * Parse via a file path or URL
|
---|
378 | *
|
---|
379 | * This method invokes the parsing process on the XML file specified by
|
---|
380 | * the Unicode string parameter 'systemId'.
|
---|
381 | *
|
---|
382 | * The parser owns the returned DOMDocument. It will be deleted
|
---|
383 | * when the parser is released.
|
---|
384 | *
|
---|
385 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
386 | *
|
---|
387 | * @param systemId A const XMLCh pointer to the Unicode string which
|
---|
388 | * contains the path to the XML file to be parsed.
|
---|
389 | * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
|
---|
390 | * and populated DOMDocument is returned. If the DOMBuilder is
|
---|
391 | * asynchronous then <code>null</code> is returned since the
|
---|
392 | * document object is not yet parsed when this method returns.
|
---|
393 | * @exception SAXException Any SAX exception, possibly
|
---|
394 | * wrapping another exception.
|
---|
395 | * @exception XMLException An exception from the parser or client
|
---|
396 | * handler code.
|
---|
397 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
398 | *
|
---|
399 | * @see #parse(DOMInputSource,...)
|
---|
400 | * @see resetDocumentPool
|
---|
401 | * @since DOM Level 3
|
---|
402 | */
|
---|
403 | virtual DOMDocument* parseURI(const XMLCh* const systemId) = 0;
|
---|
404 |
|
---|
405 | /**
|
---|
406 | * Parse via a file path or URL (in the local code page)
|
---|
407 | *
|
---|
408 | * This method invokes the parsing process on the XML file specified by
|
---|
409 | * the native char* string parameter 'systemId'.
|
---|
410 | *
|
---|
411 | * The parser owns the returned DOMDocument. It will be deleted
|
---|
412 | * when the parser is released.
|
---|
413 | *
|
---|
414 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
415 | *
|
---|
416 | * @param systemId A const char pointer to a native string which
|
---|
417 | * contains the path to the XML file to be parsed.
|
---|
418 | * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
|
---|
419 | * and populated DOMDocument is returned. If the DOMBuilder is
|
---|
420 | * asynchronous then <code>null</code> is returned since the
|
---|
421 | * document object is not yet parsed when this method returns.
|
---|
422 | * @exception SAXException Any SAX exception, possibly
|
---|
423 | * wrapping another exception.
|
---|
424 | * @exception XMLException An exception from the parser or client
|
---|
425 | * handler code.
|
---|
426 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
427 | *
|
---|
428 | * @see #parse(DOMInputSource,...)
|
---|
429 | * @see resetDocumentPool
|
---|
430 | */
|
---|
431 | virtual DOMDocument* parseURI(const char* const systemId) = 0;
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Parse via an input source object
|
---|
435 | *
|
---|
436 | * This method invokes the parsing process on the XML file specified
|
---|
437 | * by the DOMInputSource parameter, and inserts the content into an
|
---|
438 | * existing document at the position specified with the contextNode
|
---|
439 | * and action arguments. When parsing the input stream the context node
|
---|
440 | * is used for resolving unbound namespace prefixes.
|
---|
441 | *
|
---|
442 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
443 | *
|
---|
444 | * @param source A const reference to the DOMInputSource object which
|
---|
445 | * points to the XML file to be parsed.
|
---|
446 | * @param contextNode The node that is used as the context for the data
|
---|
447 | * that is being parsed. This node must be a Document
|
---|
448 | * node, a DocumentFragment node, or a node of a type
|
---|
449 | * that is allowed as a child of an element, e.g. it
|
---|
450 | * can not be an attribute node.
|
---|
451 | * @param action This parameter describes which action should be taken
|
---|
452 | * between the new set of node being inserted and the
|
---|
453 | * existing children of the context node.
|
---|
454 | * @exception DOMException
|
---|
455 | * NOT_SUPPORTED_ERR: Raised when the DOMBuilder doesn't support
|
---|
456 | * this method.
|
---|
457 | * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is
|
---|
458 | * readonly.
|
---|
459 | * @since DOM Level 3
|
---|
460 | */
|
---|
461 | virtual void parseWithContext
|
---|
462 | (
|
---|
463 | const DOMInputSource& source
|
---|
464 | , DOMNode* const contextNode
|
---|
465 | , const short action
|
---|
466 | ) = 0;
|
---|
467 | //@}
|
---|
468 |
|
---|
469 | // -----------------------------------------------------------------------
|
---|
470 | // Non-standard Extension
|
---|
471 | // -----------------------------------------------------------------------
|
---|
472 | /** @name Non-standard Extension */
|
---|
473 | //@{
|
---|
474 |
|
---|
475 | /**
|
---|
476 | * Query the current value of a property in a DOMBuilder.
|
---|
477 | *
|
---|
478 | * The builder owns the returned pointer. The memory allocated for
|
---|
479 | * the returned pointer will be destroyed when the builder is deleted.
|
---|
480 | *
|
---|
481 | * To ensure assessiblity of the returned information after the builder
|
---|
482 | * is deleted, callers need to copy and store the returned information
|
---|
483 | * somewhere else; otherwise you may get unexpected result. Since the returned
|
---|
484 | * pointer is a generic void pointer, see
|
---|
485 | * http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn
|
---|
486 | * exactly what type of property value each property returns for replication.
|
---|
487 | *
|
---|
488 | * @param name The unique identifier (URI) of the property being set.
|
---|
489 | * @return The current value of the property. The pointer spans the same
|
---|
490 | * life-time as the parser. A null pointer is returned if nothing
|
---|
491 | * was specified externally.
|
---|
492 | * @exception DOMException
|
---|
493 | * <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
|
---|
494 | * the requested property.
|
---|
495 | */
|
---|
496 | virtual void* getProperty(const XMLCh* const name) const = 0 ;
|
---|
497 |
|
---|
498 | /**
|
---|
499 | * Set the value of any property in a DOMBuilder.
|
---|
500 | * See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties for
|
---|
501 | * the list of supported properties.
|
---|
502 | *
|
---|
503 | * It takes a void pointer as the property value. Application is required to initialize this void
|
---|
504 | * pointer to a correct type. See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties
|
---|
505 | * to learn exactly what type of property value each property expects for processing.
|
---|
506 | * Passing a void pointer that was initialized with a wrong type will lead to unexpected result.
|
---|
507 | * If the same property is set more than once, the last one takes effect.
|
---|
508 | *
|
---|
509 | * @param name The unique identifier (URI) of the property being set.
|
---|
510 | * @param value The requested value for the property.
|
---|
511 | * See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn
|
---|
512 | * exactly what type of property value each property expects for processing.
|
---|
513 | * Passing a void pointer that was initialized with a wrong type will lead
|
---|
514 | * to unexpected result.
|
---|
515 | * @exception DOMException
|
---|
516 | * <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
|
---|
517 | * the requested property.
|
---|
518 | */
|
---|
519 | virtual void setProperty(const XMLCh* const name, void* value) = 0 ;
|
---|
520 |
|
---|
521 | /**
|
---|
522 | * Called to indicate that this DOMBuilder is no longer in use
|
---|
523 | * and that the implementation may relinquish any resources associated with it.
|
---|
524 | *
|
---|
525 | * Access to a released object will lead to unexpected result.
|
---|
526 | */
|
---|
527 | virtual void release() = 0;
|
---|
528 |
|
---|
529 | /** Reset the documents vector pool and release all the associated memory
|
---|
530 | * back to the system.
|
---|
531 | *
|
---|
532 | * When parsing a document using a DOM parser, all memory allocated
|
---|
533 | * for a DOM tree is associated to the DOM document.
|
---|
534 | *
|
---|
535 | * If you do multiple parse using the same DOM parser instance, then
|
---|
536 | * multiple DOM documents will be generated and saved in a vector pool.
|
---|
537 | * All these documents (and thus all the allocated memory)
|
---|
538 | * won't be deleted until the parser instance is destroyed.
|
---|
539 | *
|
---|
540 | * If you don't need these DOM documents anymore and don't want to
|
---|
541 | * destroy the DOM parser instance at this moment, then you can call this method
|
---|
542 | * to reset the document vector pool and release all the allocated memory
|
---|
543 | * back to the system.
|
---|
544 | *
|
---|
545 | * It is an error to call this method if you are in the middle of a
|
---|
546 | * parse (e.g. in the mid of a progressive parse).
|
---|
547 | *
|
---|
548 | * @exception IOException An exception from the parser if this function
|
---|
549 | * is called when a parse is in progress.
|
---|
550 | *
|
---|
551 | */
|
---|
552 | virtual void resetDocumentPool() = 0;
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
|
---|
556 | * object.
|
---|
557 | *
|
---|
558 | * This method invokes the preparsing process on a schema grammar XML
|
---|
559 | * file specified by the DOMInputSource parameter. If the 'toCache' flag
|
---|
560 | * is enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
561 | * key is found in the pool, no caching of any grammar will take place.
|
---|
562 | *
|
---|
563 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
564 | *
|
---|
565 | * @param source A const reference to the DOMInputSource object which
|
---|
566 | * points to the schema grammar file to be preparsed.
|
---|
567 | * @param grammarType The grammar type (Schema or DTD).
|
---|
568 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
569 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
570 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
571 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
572 | *
|
---|
573 | * @exception SAXException Any SAX exception, possibly
|
---|
574 | * wrapping another exception.
|
---|
575 | * @exception XMLException An exception from the parser or client
|
---|
576 | * handler code.
|
---|
577 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
578 | *
|
---|
579 | * @see DOMInputSource#DOMInputSource
|
---|
580 | */
|
---|
581 | virtual Grammar* loadGrammar(const DOMInputSource& source,
|
---|
582 | const short grammarType,
|
---|
583 | const bool toCache = false) = 0;
|
---|
584 |
|
---|
585 | /**
|
---|
586 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
|
---|
587 | *
|
---|
588 | * This method invokes the preparsing process on a schema grammar XML
|
---|
589 | * file specified by the file path parameter. If the 'toCache' flag is
|
---|
590 | * enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
591 | * key is found in the pool, no caching of any grammar will take place.
|
---|
592 | *
|
---|
593 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
594 | *
|
---|
595 | * @param systemId A const XMLCh pointer to the Unicode string which
|
---|
596 | * contains the path to the XML grammar file to be
|
---|
597 | * preparsed.
|
---|
598 | * @param grammarType The grammar type (Schema or DTD).
|
---|
599 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
600 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
601 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
602 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
603 | *
|
---|
604 | * @exception SAXException Any SAX exception, possibly
|
---|
605 | * wrapping another exception.
|
---|
606 | * @exception XMLException An exception from the parser or client
|
---|
607 | * handler code.
|
---|
608 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
609 | */
|
---|
610 | virtual Grammar* loadGrammar(const XMLCh* const systemId,
|
---|
611 | const short grammarType,
|
---|
612 | const bool toCache = false) = 0;
|
---|
613 |
|
---|
614 | /**
|
---|
615 | * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
|
---|
616 | *
|
---|
617 | * This method invokes the preparsing process on a schema grammar XML
|
---|
618 | * file specified by the file path parameter. If the 'toCache' flag is
|
---|
619 | * enabled, the parser will cache the grammars for re-use. If a grammar
|
---|
620 | * key is found in the pool, no caching of any grammar will take place.
|
---|
621 | *
|
---|
622 | * <p><b>"Experimental - subject to change"</b></p>
|
---|
623 | *
|
---|
624 | * @param systemId A const char pointer to a native string which contains
|
---|
625 | * the path to the XML grammar file to be preparsed.
|
---|
626 | * @param grammarType The grammar type (Schema or DTD).
|
---|
627 | * @param toCache If <code>true</code>, we cache the preparsed grammar,
|
---|
628 | * otherwise, no chaching. Default is <code>false</code>.
|
---|
629 | * @return The preparsed schema grammar object (SchemaGrammar or
|
---|
630 | * DTDGrammar). That grammar object is owned by the parser.
|
---|
631 | *
|
---|
632 | *
|
---|
633 | * @exception SAXException Any SAX exception, possibly
|
---|
634 | * wrapping another exception.
|
---|
635 | * @exception XMLException An exception from the parser or client
|
---|
636 | * handler code.
|
---|
637 | * @exception DOMException A DOM exception as per DOM spec.
|
---|
638 | */
|
---|
639 | virtual Grammar* loadGrammar(const char* const systemId,
|
---|
640 | const short grammarType,
|
---|
641 | const bool toCache = false) = 0;
|
---|
642 |
|
---|
643 | /**
|
---|
644 | * Retrieve the grammar that is associated with the specified namespace key
|
---|
645 | *
|
---|
646 | * @param nameSpaceKey Namespace key
|
---|
647 | * @return Grammar associated with the Namespace key.
|
---|
648 | */
|
---|
649 | virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) const = 0;
|
---|
650 |
|
---|
651 | /**
|
---|
652 | * Retrieve the grammar where the root element is declared.
|
---|
653 | *
|
---|
654 | * @return Grammar where root element declared
|
---|
655 | */
|
---|
656 | virtual Grammar* getRootGrammar() const = 0;
|
---|
657 |
|
---|
658 | /**
|
---|
659 | * Returns the string corresponding to a URI id from the URI string pool.
|
---|
660 | *
|
---|
661 | * @param uriId id of the string in the URI string pool.
|
---|
662 | * @return URI string corresponding to the URI id.
|
---|
663 | */
|
---|
664 | virtual const XMLCh* getURIText(unsigned int uriId) const = 0;
|
---|
665 |
|
---|
666 | /**
|
---|
667 | * Clear the cached grammar pool
|
---|
668 | */
|
---|
669 | virtual void resetCachedGrammarPool() = 0;
|
---|
670 |
|
---|
671 | /**
|
---|
672 | * Returns the current src offset within the input source.
|
---|
673 | *
|
---|
674 | * @return offset within the input source
|
---|
675 | */
|
---|
676 | virtual unsigned int getSrcOffset() const = 0;
|
---|
677 |
|
---|
678 | //@}
|
---|
679 |
|
---|
680 | };
|
---|
681 |
|
---|
682 |
|
---|
683 | XERCES_CPP_NAMESPACE_END
|
---|
684 |
|
---|
685 | #endif
|
---|