source: NonGTP/Xerces/xercesc/parsers/DOMBuilderImpl.hpp @ 188

Revision 188, 38.7 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

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