source: NonGTP/Xerces/xerces/include/xercesc/parsers/DOMBuilderImpl.hpp @ 358

Revision 358, 36.7 KB checked in by bittner, 19 years ago (diff)

xerces added

Line 
1/*
2 * Copyright 2002,2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * $Id: DOMBuilderImpl.hpp,v 1.17 2004/09/08 13:56:17 peiyongz Exp $
19 *
20 */
21
22#if !defined(DOMBUILDERIMPL_HPP)
23#define DOMBUILDERIMPL_HPP
24
25
26#include <xercesc/parsers/AbstractDOMParser.hpp>
27#include <xercesc/dom/DOMBuilder.hpp>
28#include <xercesc/util/XercesDefs.hpp>
29
30
31XERCES_CPP_NAMESPACE_BEGIN
32
33class XMLEntityResolver;
34class XMLResourceIdentifier;
35
36 /**
37  * Introduced in DOM Level 3
38  *
39  * DOMBuilderImpl provides an implementation of a DOMBuilder interface.
40  * A DOMBuilder instance is obtained from the DOMImplementationLS interface
41  * by invoking its createDOMBuilder method.
42  */
43class PARSERS_EXPORT DOMBuilderImpl : public AbstractDOMParser,
44                                      public DOMBuilder
45{
46public :
47    // -----------------------------------------------------------------------
48    //  Constructors and Detructor
49    // -----------------------------------------------------------------------
50
51    /** @name Constructors and Destructor */
52    //@{
53    /** Construct a DOMBuilderImpl, with an optional validator
54      *
55      * Constructor with an instance of validator class to use for
56      * validation. If you don't provide a validator, a default one will
57      * be created for you in the scanner.
58      *
59      * @param gramPool   Pointer to the grammar pool instance from
60      *                   external application.
61      *                   The parser does NOT own it.
62      *
63      * @param valToAdopt Pointer to the validator instance to use. The
64      *                   parser is responsible for freeing the memory.
65      */
66    DOMBuilderImpl
67    (
68          XMLValidator* const   valToAdopt = 0
69        , MemoryManager* const  manager = XMLPlatformUtils::fgMemoryManager
70        , XMLGrammarPool* const gramPool = 0       
71    );
72
73    /**
74      * Destructor
75      */
76    virtual ~DOMBuilderImpl();
77
78    //@}
79
80    // -----------------------------------------------------------------------
81    //  Implementation of DOMBuilder interface
82    // -----------------------------------------------------------------------
83    // -----------------------------------------------------------------------
84    //  Getter methods
85    // -----------------------------------------------------------------------
86
87    /** @name Getter methods */
88    //@{
89
90    /**
91      * <p><b>"Experimental - subject to change"</b></p>
92      *
93      * Get a pointer to the error handler
94      *
95      * This method returns the installed error handler. If no handler
96      * has been installed, then it will be a zero pointer.
97      *
98      * @return The pointer to the installed error handler object.
99      */
100    DOMErrorHandler* getErrorHandler();
101
102    /**
103      * <p><b>"Experimental - subject to change"</b></p>
104      *
105      * Get a const pointer to the error handler
106      *
107      * This method returns the installed error handler.  If no handler
108      * has been installed, then it will be a zero pointer.
109      *
110      * @return A const pointer to the installed error handler object.
111      */
112    const DOMErrorHandler* getErrorHandler() const;
113
114    /**
115      * <p><b>"Experimental - subject to change"</b></p>
116      *
117      * Get a pointer to the entity resolver
118      *
119      * This method returns the installed entity resolver.  If no resolver
120      * has been installed, then it will be a zero pointer.
121      *
122      * @return The pointer to the installed entity resolver object.
123      */
124    DOMEntityResolver* getEntityResolver();
125
126    /**
127      * Get a pointer to the entity resolver
128      *
129      * This method returns the installed entity resolver.  If no resolver
130      * has been installed, then it will be a zero pointer.
131      *
132      * @return The pointer to the installed entity resolver object.
133      */
134    XMLEntityResolver* getXMLEntityResolver();
135 
136    /**
137      * Get a const pointer to the entity resolver
138      *
139      * This method returns the installed entity resolver. If no resolver
140      * has been installed, then it will be a zero pointer.
141      *
142      * @return A const pointer to the installed entity resolver object.
143      */
144    const XMLEntityResolver* getXMLEntityResolver() const;
145
146    /**
147      * <p><b>"Experimental - subject to change"</b></p>
148      *
149      * Get a const pointer to the entity resolver
150      *
151      * This method returns the installed entity resolver. If no resolver
152      * has been installed, then it will be a zero pointer.
153      *
154      * @return A const pointer to the installed entity resolver object.
155      */
156    const DOMEntityResolver* getEntityResolver() const;
157
158    /**
159      * <p><b>"Experimental - subject to change"</b></p>
160      *
161      * Get a pointer to the application filter
162      *
163      * This method returns the installed application filter. If no filter
164      * has been installed, then it will be a zero pointer.
165      *
166      * @return The pointer to the installed application filter.
167      */
168    DOMBuilderFilter* getFilter();
169
170    /**
171      * <p><b>"Experimental - subject to change"</b></p>
172      *
173      * Get a const pointer to the application filter
174      *
175      * This method returns the installed application filter. If no filter
176      * has been installed, then it will be a zero pointer.
177      *
178      * @return A const pointer to the installed application filter
179      */
180    const DOMBuilderFilter* getFilter() const;
181
182    //@}
183
184
185    // -----------------------------------------------------------------------
186    //  Setter methods
187    // -----------------------------------------------------------------------
188
189    /** @name Setter methods */
190    //@{
191
192    /**
193      * <p><b>"Experimental - subject to change"</b></p>
194      *
195      * Set the error handler
196      *
197      * This method allows applications to install their own error handler
198      * to trap error and warning messages.
199      *
200      * <i>Any previously set handler is merely dropped, since the parser
201      * does not own them.</i>
202      *
203      * @param handler  A const pointer to the user supplied error
204      *                 handler.
205      *
206      * @see #getErrorHandler
207      */
208    void setErrorHandler(DOMErrorHandler* const handler);
209
210    /**
211      * <p><b>"Experimental - subject to change"</b></p>
212      *
213      * Set the entity resolver
214      *
215      * This method allows applications to install their own entity
216      * resolver. By installing an entity resolver, the applications
217      * can trap and potentially redirect references to external
218      * entities.
219      *
220      * <i>Any previously set entity resolver is merely dropped, since the parser
221      * does not own them.  If both setEntityResolver and setXMLEntityResolver
222      * are called, then the last one is used.</i>
223      *
224      * @param handler  A const pointer to the user supplied entity
225      *                 resolver.
226      *
227      * @see #getEntityResolver
228      */
229    void setEntityResolver(DOMEntityResolver* const handler);
230
231    /**
232      * Set the entity resolver
233      *
234      * This method allows applications to install their own entity
235      * resolver. By installing an entity resolver, the applications
236      * can trap and potentially redirect references to external
237      * entities.
238      *
239      * <i>Any previously set entity resolver is merely dropped, since the parser
240      * does not own them.  If both setEntityResolver and setXMLEntityResolver
241      * are called, then the last one is used.</i>
242      *
243      * @param handler  A const pointer to the user supplied entity
244      *                 resolver.
245      *
246      * @see #getXMLEntityResolver
247      */
248    void setXMLEntityResolver(XMLEntityResolver* const handler);
249
250    /**
251      * <p><b>"Experimental - subject to change"</b></p>
252      *
253      * Set the application filter
254      *
255      * When the application provides a filter, the parser will call out to
256      * the filter at the completion of the construction of each Element node.
257      * The filter implementation can choose to remove the element from the
258      * document being constructed (unless the element is the document element)
259      * or to terminate the parse early. If the document is being validated
260      * when it's loaded the validation happens before the filter is called.
261      *
262      * <i>Any previously set filter is merely dropped, since the parser
263      * does not own them.</i>
264      *
265      * @param filter  A const pointer to the user supplied application
266      *                filter.
267      *
268      * @see #getFilter
269      */
270    void setFilter(DOMBuilderFilter* const filter);
271
272    //@}
273
274
275    // -----------------------------------------------------------------------
276    //  Feature methods
277    // -----------------------------------------------------------------------
278    /** @name Feature methods */
279    //@{
280
281    /**
282      * <p><b>"Experimental - subject to change"</b></p>
283      *
284      * Set the state of a feature
285      *
286      * It is possible for a DOMBuilder to recognize a feature name but to be
287      * unable to set its value.
288      *
289      * @param name  The feature name.
290      * @param state The requested state of the feature (true or false).
291      * @exception DOMException
292      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder recognizes the
293      *     feature name but cannot set the requested value.
294      *     <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
295      *     the feature name.
296      *
297      * @see #getFeature
298      * @see #canSetFeature
299      */
300    void setFeature(const XMLCh* const name, const bool state);
301
302    /**
303      * <p><b>"Experimental - subject to change"</b></p>
304      *
305      * Look up the value of a feature.
306      *
307      * @param name The feature name.
308      * @return The current state of the feature (true or false)
309      * @exception DOMException
310      *     NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
311      *     the feature name.
312      *
313      * @see #setFeature
314      * @see #canSetFeature
315      */
316    bool getFeature(const XMLCh* const name) const;
317
318    /**
319      * <p><b>"Experimental - subject to change"</b></p>
320      *
321      * Query whether setting a feature to a specific value is supported.
322      *
323      * @param name  The feature name.
324      * @param state The requested state of the feature (true or false).
325      * @return <code>true</code> if the feature could be successfully set
326      *     to the specified value, or <code>false</code> if the feature
327      *     is not recognized or the requested value is not supported. The
328      *     value of the feature itself is not changed.
329      *
330      * @see #getFeature
331      * @see #setFeature
332      */
333    bool canSetFeature(const XMLCh* const name, const bool state) const;
334
335    //@}
336
337    // -----------------------------------------------------------------------
338    //  Parsing methods
339    // -----------------------------------------------------------------------
340    /** @name Parsing methods */
341    //@{
342
343    /**
344      * <p><b>"Experimental - subject to change"</b></p>
345      *
346      * Parse via an input source object
347      *
348      * This method invokes the parsing process on the XML file specified
349      * by the DOMInputSource parameter. This API is borrowed from the
350      * SAX Parser interface.
351      *
352      * @param source A const reference to the DOMInputSource object which
353      *               points to the XML file to be parsed.
354      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
355      *         and populated Document is returned. If the DOMBuilder is
356      *         asynchronous then <code>null</code> is returned since the
357      *         document object is not yet parsed when this method returns.
358      * @exception SAXException Any SAX exception, possibly
359      *            wrapping another exception.
360      * @exception XMLException An exception from the parser or client
361      *            handler code.
362      * @exception DOMException A DOM exception as per DOM spec.
363      *
364      * @see DOMInputSource#DOMInputSource
365      * @see #setEntityResolver
366      * @see #setErrorHandler
367      */
368    DOMDocument* parse(const DOMInputSource& source);
369
370    /**
371      * <p><b>"Experimental - subject to change"</b></p>
372      *
373      * Parse via a file path or URL
374      *
375      * This method invokes the parsing process on the XML file specified by
376      * the Unicode string parameter 'systemId'.
377      *
378      * @param systemId A const XMLCh pointer to the Unicode string which
379      *                 contains the path to the XML file to be parsed.
380      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
381      *         and populated Document is returned. If the DOMBuilder is
382      *         asynchronous then <code>null</code> is returned since the
383      *         document object is not yet parsed when this method returns.
384      * @exception SAXException Any SAX exception, possibly
385      *            wrapping another exception.
386      * @exception XMLException An exception from the parser or client
387      *            handler code.
388      * @exception DOM_DOMException A DOM exception as per DOM spec.
389      *
390      * @see #parse(DOMInputSource,...)
391      */
392    DOMDocument* parseURI(const XMLCh* const systemId);
393
394    /**
395      * <p><b>"Experimental - subject to change"</b></p>
396      *
397      * Parse via a file path or URL (in the local code page)
398      *
399      * This method invokes the parsing process on the XML file specified by
400      * the native char* string parameter 'systemId'.
401      *
402      * @param systemId A const char pointer to a native string which
403      *                 contains the path to the XML file to be parsed.
404      * @return If the DOMBuilder is a synchronous DOMBuilder the newly created
405      *         and populated Document is returned. If the DOMBuilder is
406      *         asynchronous then <code>null</code> is returned since the
407      *         document object is not yet parsed when this method returns.
408      * @exception SAXException Any SAX exception, possibly
409      *            wrapping another exception.
410      * @exception XMLException An exception from the parser or client
411      *            handler code.
412      * @exception DOM_DOMException A DOM exception as per DOM spec.
413      *
414      * @see #parse(DOMInputSource,...)
415      */
416    DOMDocument* parseURI(const char* const systemId);
417
418    /**
419      * <p><b>"Experimental - subject to change"</b></p>
420      *
421      * Parse via an input source object
422      *
423      * This method invokes the parsing process on the XML file specified
424      * by the DOMInputSource parameter, and inserts the content into an
425      * existing document at the position specified with the contextNode
426      * and action arguments. When parsing the input stream the context node
427      * is used for resolving unbound namespace prefixes.
428      *
429      * @param source A const reference to the DOMInputSource object which
430      *               points to the XML file to be parsed.
431      * @param contextNode The node that is used as the context for the data
432      *                    that is being parsed. This node must be a Document
433      *                    node, a DocumentFragment node, or a node of a type
434      *                    that is allowed as a child of an element, e.g. it
435      *                    can not be an attribute node.
436      * @param action This parameter describes which action should be taken
437      *               between the new set of node being inserted and the
438      *               existing children of the context node.
439      * @exception DOMException
440      *     NOT_SUPPORTED_ERR: Raised when the DOMBuilder doesn't support
441      *     this method.
442      *     <br>NO_MODIFICATION_ALLOWED_ERR: Raised if the context node is
443      *     readonly.
444      */
445    virtual void parseWithContext
446    (
447        const   DOMInputSource& source
448        ,       DOMNode* const contextNode
449        , const short action
450    );
451
452
453    // -----------------------------------------------------------------------
454    //  Non-standard Extension
455    // -----------------------------------------------------------------------
456    /** @name Non-standard Extension */
457    //@{
458
459    /**
460      * Query the current value of a property in a DOMBuilder.
461      *
462      * The builder owns the returned pointer.  The memory allocated for
463      * the returned pointer will be destroyed when the builder is deleted.
464      *
465      * To ensure assessiblity of the returned information after the builder
466      * is deleted, callers need to copy and store the returned information
467      * somewhere else; otherwise you may get unexpected result.  Since the returned
468      * pointer is a generic void pointer, see
469      * http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn
470      * exactly what type of property value each property returns for replication.
471      *
472      * @param name The unique identifier (URI) of the property being set.
473      * @return     The current value of the property.  The pointer spans the same
474      *             life-time as the parser.  A null pointer is returned if nothing
475      *             was specified externally.
476      * @exception DOMException
477      *     <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
478      *     the requested property.
479      */
480    virtual void* getProperty(const XMLCh* const name) const;
481
482    /**
483      * Set the value of any property in a DOMBuilder.
484      * See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties for
485      * the list of supported properties.
486      *
487      * It takes a void pointer as the property value.  Application is required to initialize this void
488      * pointer to a correct type.  See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties
489      * to learn exactly what type of property value each property expects for processing.
490      * Passing a void pointer that was initialized with a wrong type will lead to unexpected result.
491      * If the same property is set more than once, the last one takes effect.
492      *
493      * @param name The unique identifier (URI) of the property being set.
494      * @param value The requested value for the property.
495      *            See http://xml.apache.org/xerces-c/program-dom.html#DOMBuilderProperties to learn
496      *            exactly what type of property value each property expects for processing.
497      *            Passing a void pointer that was initialized with a wrong type will lead
498      *            to unexpected result.
499      * @exception DOMException
500      *     <br>NOT_FOUND_ERR: Raised when the DOMBuilder does not recognize
501      *     the requested property.
502      */
503    virtual void setProperty(const XMLCh* const name, void* value);
504
505    /**
506     * Called to indicate that this DOMBuilder is no longer in use
507     * and that the implementation may relinquish any resources associated with it.
508     *
509     */
510    virtual void              release();
511
512    /** Reset the documents vector pool and release all the associated memory
513      * back to the system.
514      *
515      * When parsing a document using a DOM parser, all memory allocated
516      * for a DOM tree is associated to the DOM document.
517      *
518      * If you do multiple parse using the same DOM parser instance, then
519      * multiple DOM documents will be generated and saved in a vector pool.
520      * All these documents (and thus all the allocated memory)
521      * won't be deleted until the parser instance is destroyed.
522      *
523      * If you don't need these DOM documents anymore and don't want to
524      * destroy the DOM parser instance at this moment, then you can call this method
525      * to reset the document vector pool and release all the allocated memory
526      * back to the system.
527      *
528      * It is an error to call this method if you are in the middle of a
529      * parse (e.g. in the mid of a progressive parse).
530      *
531      * @exception IOException An exception from the parser if this function
532      *            is called when a parse is in progress.
533      *
534      */
535    virtual void resetDocumentPool();
536
537    /**
538      * Preparse schema grammar (XML Schema, DTD, etc.) via an input source
539      * object.
540      *
541      * This method invokes the preparsing process on a schema grammar XML
542      * file specified by the DOMInputSource parameter. If the 'toCache' flag
543      * is enabled, the parser will cache the grammars for re-use. If a grammar
544      * key is found in the pool, no caching of any grammar will take place.
545      *
546      * <p><b>"Experimental - subject to change"</b></p>
547      *
548      * @param source A const reference to the DOMInputSource object which
549      *               points to the schema grammar file to be preparsed.
550      * @param grammarType The grammar type (Schema or DTD).
551      * @param toCache If <code>true</code>, we cache the preparsed grammar,
552      *                otherwise, no chaching. Default is <code>false</code>.
553      * @return The preparsed schema grammar object (SchemaGrammar or
554      *         DTDGrammar). That grammar object is owned by the parser.
555      *
556      * @exception SAXException Any SAX exception, possibly
557      *            wrapping another exception.
558      * @exception XMLException An exception from the parser or client
559      *            handler code.
560      * @exception DOMException A DOM exception as per DOM spec.
561      *
562      * @see DOMInputSource#DOMInputSource
563      */
564    virtual Grammar* loadGrammar(const DOMInputSource& source,
565                             const short grammarType,
566                             const bool toCache = false);
567
568    /**
569      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
570      *
571      * This method invokes the preparsing process on a schema grammar XML
572      * file specified by the file path parameter. If the 'toCache' flag
573      * is enabled, the parser will cache the grammars for re-use. If a grammar
574      * key is found in the pool, no caching of any grammar will take place.
575      *
576      * <p><b>"Experimental - subject to change"</b></p>
577      *
578      * @param systemId A const XMLCh pointer to the Unicode string which
579      *                 contains the path to the XML grammar file to be
580      *                 preparsed.
581      * @param grammarType The grammar type (Schema or DTD).
582      * @param toCache If <code>true</code>, we cache the preparsed grammar,
583      *                otherwise, no chaching. Default is <code>false</code>.
584      * @return The preparsed schema grammar object (SchemaGrammar or
585      *         DTDGrammar). That grammar object is owned by the parser.
586      *
587      * @exception SAXException Any SAX exception, possibly
588      *            wrapping another exception.
589      * @exception XMLException An exception from the parser or client
590      *            handler code.
591      * @exception DOMException A DOM exception as per DOM spec.
592      */
593    virtual Grammar* loadGrammar(const XMLCh* const systemId,
594                             const short grammarType,
595                             const bool toCache = false);
596
597    /**
598      * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL
599      *
600      * This method invokes the preparsing process on a schema grammar XML
601      * file specified by the file path parameter. If the 'toCache' flag
602      * is enabled, the parser will cache the grammars for re-use. If a grammar
603      * key is found in the pool, no caching of any grammar will take place.
604      *
605      * <p><b>"Experimental - subject to change"</b></p>
606      *
607      * @param systemId A const char pointer to a native string which contains
608      *                 the path to the XML grammar file to be preparsed.
609      * @param grammarType The grammar type (Schema or DTD).
610      * @param toCache If <code>true</code>, we cache the preparsed grammar,
611      *                otherwise, no chaching. Default is <code>false</code>.
612      * @return The preparsed schema grammar object (SchemaGrammar or
613      *         DTDGrammar). That grammar object is owned by the parser.
614      *
615      * @exception SAXException Any SAX exception, possibly
616      *            wrapping another exception.
617      * @exception XMLException An exception from the parser or client
618      *            handler code.
619      * @exception DOMException A DOM exception as per DOM spec.
620      */
621    virtual Grammar* loadGrammar(const char* const systemId,
622                                 const short grammarType,
623                                 const bool toCache = false);
624
625    /**
626     * Retrieve the grammar that is associated with the specified namespace key
627     *
628     * @param  nameSpaceKey Namespace key
629     * @return Grammar associated with the Namespace key.
630     */
631    virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) const;
632
633    /**
634     * Retrieve the grammar where the root element is declared.
635     *
636     * @return Grammar where root element declared
637     */
638    virtual Grammar* getRootGrammar() const;
639
640    /**
641     * Returns the string corresponding to a URI id from the URI string pool.
642     *
643     * @param uriId id of the string in the URI string pool.
644     * @return URI string corresponding to the URI id.
645     */
646    virtual const XMLCh* getURIText(unsigned int uriId) const;
647
648    /**
649      * Clear the cached grammar pool
650      */
651    virtual void resetCachedGrammarPool();
652
653    /**
654      * Returns the current src offset within the input source.
655      *
656      * @return offset within the input source
657      */
658    virtual unsigned int getSrcOffset() const;
659
660    //@}
661
662    // -----------------------------------------------------------------------
663    //  Implementation of the XMLErrorReporter interface.
664    // -----------------------------------------------------------------------
665
666    /** @name Implementation of the XMLErrorReporter interface. */
667    //@{
668
669    /** Handle errors reported from the parser
670      *
671      * This method is used to report back errors found while parsing the
672      * XML file. This method is also borrowed from the SAX specification.
673      * It calls the corresponding user installed Error Handler method:
674      * 'fatal', 'error', 'warning' depending on the severity of the error.
675      * This classification is defined by the XML specification.
676      *
677      * @param errCode An integer code for the error.
678      * @param msgDomain A const pointer to an Unicode string representing
679      *                  the message domain to use.
680      * @param errType An enumeration classifying the severity of the error.
681      * @param errorText A const pointer to an Unicode string representing
682      *                  the text of the error message.
683      * @param systemId  A const pointer to an Unicode string representing
684      *                  the system id of the XML file where this error
685      *                  was discovered.
686      * @param publicId  A const pointer to an Unicode string representing
687      *                  the public id of the XML file where this error
688      *                  was discovered.
689      * @param lineNum   The line number where the error occurred.
690      * @param colNum    The column number where the error occurred.
691      * @see DOMErrorHandler
692      */
693    virtual void error
694    (
695        const   unsigned int                errCode
696        , const XMLCh* const                msgDomain
697        , const XMLErrorReporter::ErrTypes  errType
698        , const XMLCh* const                errorText
699        , const XMLCh* const                systemId
700        , const XMLCh* const                publicId
701        , const XMLSSize_t                  lineNum
702        , const XMLSSize_t                  colNum
703    );
704
705    /** Reset any error data before a new parse
706     *
707      * This method allows the user installed Error Handler callback to
708      * 'reset' itself.
709      *
710      * <b><font color="#FF0000">This method is a no-op for this DOM
711      * implementation.</font></b>
712      */
713    virtual void resetErrors();
714    //@}
715
716
717    // -----------------------------------------------------------------------
718    //  Implementation of the XMLEntityHandler interface.
719    // -----------------------------------------------------------------------
720
721    /** @name Implementation of the XMLEntityHandler interface. */
722    //@{
723
724    /** Handle an end of input source event
725      *
726      * This method is used to indicate the end of parsing of an external
727      * entity file.
728      *
729      * <b><font color="#FF0000">This method is a no-op for this DOM
730      * implementation.</font></b>
731      *
732      * @param inputSource A const reference to the InputSource object
733      *                    which points to the XML file being parsed.
734      * @see InputSource
735      */
736    virtual void endInputSource(const InputSource& inputSource);
737
738    /** Expand a system id
739      *
740      * This method allows an installed XMLEntityHandler to further
741      * process any system id's of enternal entities encountered in
742      * the XML file being parsed, such as redirection etc.
743      *
744      * <b><font color="#FF0000">This method always returns 'false'
745      * for this DOM implementation.</font></b>
746      *
747      * @param systemId  A const pointer to an Unicode string representing
748      *                  the system id scanned by the parser.
749      * @param toFill    A pointer to a buffer in which the application
750      *                  processed system id is stored.
751      * @return 'true', if any processing is done, 'false' otherwise.
752      */
753    virtual bool expandSystemId
754    (
755        const   XMLCh* const    systemId
756        ,       XMLBuffer&      toFill
757    );
758
759    /** Reset any entity handler information
760      *
761      * This method allows the installed XMLEntityHandler to reset
762      * itself.
763      *
764      * <b><font color="#FF0000">This method is a no-op for this DOM
765      * implementation.</font></b>
766      */
767    virtual void resetEntities();
768
769    /** Resolve a public/system id
770      *
771      * This method allows a user installed entity handler to further
772      * process any pointers to external entities. The applications can
773      * implement 'redirection' via this callback. This method is also
774      * borrowed from the SAX specification.
775      *
776      * @deprecated This method is no longer called (the other resolveEntity one is).
777      *
778      * @param publicId A const pointer to a Unicode string representing the
779      *                 public id of the entity just parsed.
780      * @param systemId A const pointer to a Unicode string representing the
781      *                 system id of the entity just parsed.
782      * @param baseURI  A const pointer to a Unicode string representing the
783      *                 base URI of the entity just parsed,
784      *                 or <code>null</code> if there is no base URI.
785      * @return The value returned by the user installed resolveEntity
786      *         method or NULL otherwise to indicate no processing was done.
787      *         The returned InputSource is owned by the DOMBuilder which is
788      *         responsible to clean up the memory.
789      * @see DOMEntityResolver
790      * @see XMLEntityHandler
791      */
792    virtual InputSource* resolveEntity
793    (
794        const   XMLCh* const    publicId
795        , const XMLCh* const    systemId
796        , const XMLCh* const    baseURI = 0
797    );
798
799    /** Resolve a public/system id
800      *
801      * This method allows a user installed entity handler to further
802      * process any pointers to external entities. The applications can
803      * implement 'redirection' via this callback. 
804      *
805      * @param resourceIdentifier An object containing the type of
806      *        resource to be resolved and the associated data members
807      *        corresponding to this type.
808      * @return The value returned by the user installed resolveEntity
809      *         method or NULL otherwise to indicate no processing was done.
810      *         The returned InputSource is owned by the parser which is
811      *         responsible to clean up the memory.
812      * @see XMLEntityHandler
813      * @see XMLEntityResolver
814      */
815    virtual InputSource* resolveEntity
816    (
817        XMLResourceIdentifier* resourceIdentifier
818    );
819
820    /** Handle a 'start input source' event
821      *
822      * This method is used to indicate the start of parsing an external
823      * entity file.
824      *
825      * <b><font color="#FF0000">This method is a no-op for this DOM parse
826      * implementation.</font></b>
827      *
828      * @param inputSource A const reference to the InputSource object
829      *                    which points to the external entity
830      *                    being parsed.
831      */
832    virtual void startInputSource(const InputSource& inputSource);
833
834    //@}
835
836
837private :
838    // -----------------------------------------------------------------------
839    //  Private data members
840    //
841    //  fEntityResolver
842    //      The installed DOM entity resolver, if any. Null if none.
843    //
844    //  fErrorHandler
845    //      The installed DOM error handler, if any. Null if none.
846    //
847    //  fFilter
848    //      The installed application filter, if any. Null if none.
849    //
850    //  fCharsetOverridesXMLEncoding
851    //      Indicates if the "charset-overrides-xml-encoding" is set or not
852    //
853    //  fUserAdoptsDocument
854    //      The DOMDocument ownership has been transferred to application
855    //      If set to true, the parser does not own the document anymore
856    //      and thus will not release its memory.
857    //-----------------------------------------------------------------------
858    bool                        fAutoValidation;
859    bool                        fValidation;
860    DOMEntityResolver*          fEntityResolver;
861    XMLEntityResolver*          fXMLEntityResolver;
862    DOMErrorHandler*            fErrorHandler;
863    DOMBuilderFilter*           fFilter;
864    bool                        fCharsetOverridesXMLEncoding;
865    bool                        fUserAdoptsDocument;
866
867    // -----------------------------------------------------------------------
868    // Unimplemented constructors and operators
869    // -----------------------------------------------------------------------
870    DOMBuilderImpl(const DOMBuilderImpl &);
871    DOMBuilderImpl & operator = (const DOMBuilderImpl &);
872};
873
874
875
876// ---------------------------------------------------------------------------
877//  DOMBuilderImpl: Handlers for the XMLEntityHandler interface
878// ---------------------------------------------------------------------------
879inline void DOMBuilderImpl::endInputSource(const InputSource&)
880{
881    // The DOM entity resolver doesn't handle this
882}
883
884inline bool DOMBuilderImpl::expandSystemId(const XMLCh* const, XMLBuffer&)
885{
886    // The DOM entity resolver doesn't handle this
887    return false;
888}
889
890inline void DOMBuilderImpl::resetEntities()
891{
892    // Nothing to do on this one
893}
894
895inline void DOMBuilderImpl::startInputSource(const InputSource&)
896{
897    // The DOM entity resolver doesn't handle this
898}
899
900
901// ---------------------------------------------------------------------------
902//  DOMBuilderImpl: Getter methods
903// ---------------------------------------------------------------------------
904inline DOMErrorHandler* DOMBuilderImpl::getErrorHandler()
905{
906    return fErrorHandler;
907}
908
909inline const DOMErrorHandler* DOMBuilderImpl::getErrorHandler() const
910{
911    return fErrorHandler;
912}
913
914inline DOMEntityResolver* DOMBuilderImpl::getEntityResolver()
915{
916    return fEntityResolver;
917}
918
919inline const DOMEntityResolver* DOMBuilderImpl::getEntityResolver() const
920{
921    return fEntityResolver;
922}
923
924inline XMLEntityResolver* DOMBuilderImpl::getXMLEntityResolver()
925{
926    return fXMLEntityResolver;
927}
928
929inline const XMLEntityResolver* DOMBuilderImpl::getXMLEntityResolver() const
930{
931    return fXMLEntityResolver;
932}
933
934inline DOMBuilderFilter* DOMBuilderImpl::getFilter()
935{
936    return fFilter;
937}
938
939inline const DOMBuilderFilter* DOMBuilderImpl::getFilter() const
940{
941    return fFilter;
942}
943
944
945XERCES_CPP_NAMESPACE_END
946
947#endif
Note: See TracBrowser for help on using the repository browser.