source: NonGTP/Xerces/xercesc/sax/DocumentHandler.hpp @ 188

Revision 188, 13.2 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) 1999-2000 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) 1999, 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 * $Log: DocumentHandler.hpp,v $
59 * Revision 1.3  2003/03/07 18:10:06  tng
60 * Return a reference instead of void for operator=
61 *
62 * Revision 1.2  2002/11/04 14:56:25  tng
63 * C++ Namespace Support.
64 *
65 * Revision 1.1.1.1  2002/02/01 22:22:08  peiyongz
66 * sane_include
67 *
68 * Revision 1.6  2000/03/02 19:54:34  roddey
69 * This checkin includes many changes done while waiting for the
70 * 1.1.0 code to be finished. I can't list them all here, but a list is
71 * available elsewhere.
72 *
73 * Revision 1.5  2000/02/24 20:12:55  abagchi
74 * Swat for removing Log from API docs
75 *
76 * Revision 1.4  2000/02/12 03:31:55  rahulj
77 * Removed duplicate CVS Log entries.
78 *
79 * Revision 1.3  2000/02/12 01:27:19  aruna1
80 * Documentation updated
81 *
82 * Revision 1.2  2000/02/06 07:47:57  rahulj
83 * Year 2K copyright swat.
84 *
85 * Revision 1.1.1.1  1999/11/09 01:07:43  twl
86 * Initial checkin
87 *
88 * Revision 1.2  1999/11/08 20:44:54  rahul
89 * Swat for adding in Product name and CVS comment log variable.
90 *
91 */
92
93
94#ifndef DOCUMENTHANDLER_HPP
95#define DOCUMENTHANDLER_HPP
96
97#include <xercesc/util/XercesDefs.hpp>
98
99XERCES_CPP_NAMESPACE_BEGIN
100
101class AttributeList;
102class Locator;
103
104/**
105  * Receive notification of general document events.
106  *
107  * <p>This is the main interface that most SAX applications
108  * implement: if the application needs to be informed of basic parsing
109  * events, it implements this interface and registers an instance with
110  * the SAX parser using the setDocumentHandler method.  The parser
111  * uses the instance to report basic document-related events like
112  * the start and end of elements and character data.</p>
113  *
114  * <p>The order of events in this interface is very important, and
115  * mirrors the order of information in the document itself.  For
116  * example, all of an element's content (character data, processing
117  * instructions, and/or subelements) will appear, in order, between
118  * the startElement event and the corresponding endElement event.</p>
119  *
120  * <p>Application writers who do not want to implement the entire
121  * interface while can derive a class from HandlerBase, which implements
122  * the default functionality; parser writers can instantiate
123  * HandlerBase to obtain a default handler.  The application can find
124  * the location of any document event using the Locator interface
125  * supplied by the Parser through the setDocumentLocator method.</p>
126  *
127  * @see Parser#setDocumentHandler
128  * @see Locator#Locator
129  * @see HandlerBase#HandlerBase
130  */
131
132class SAX_EXPORT DocumentHandler
133{
134public:
135    /** @name Constructors and Destructor */
136    //@{
137    /** Default constructor */
138    DocumentHandler()
139    {
140    }
141
142    /** Destructor */
143    virtual ~DocumentHandler()
144    {
145    }
146    //@}
147
148    /** @name The virtual document handler interface */
149
150    //@{
151   /**
152    * Receive notification of character data.
153    *
154    * <p>The Parser will call this method to report each chunk of
155    * character data.  SAX parsers may return all contiguous character
156    * data in a single chunk, or they may split it into several
157    * chunks; however, all of the characters in any single event
158    * must come from the same external entity, so that the Locator
159    * provides useful information.</p>
160    *
161    * <p>The application must not attempt to read from the array
162    * outside of the specified range.</p>
163    *
164    * <p>Note that some parsers will report whitespace using the
165    * ignorableWhitespace() method rather than this one (validating
166    * parsers must do so).</p>
167    *
168    * @param chars The characters from the XML document.
169    * @param length The number of characters to read from the array.
170    * @exception SAXException Any SAX exception, possibly
171    *            wrapping another exception.
172    * @see #ignorableWhitespace
173    * @see Locator#Locator
174    */
175    virtual void characters
176    (
177        const   XMLCh* const    chars
178        , const unsigned int    length
179    ) = 0;
180
181  /**
182    * Receive notification of the end of a document.
183    *
184    * <p>The SAX parser will invoke this method only once, and it will
185    * be the last method invoked during the parse.  The parser shall
186    * not invoke this method until it has either abandoned parsing
187    * (because of an unrecoverable error) or reached the end of
188    * input.</p>
189    *
190    * @exception SAXException Any SAX exception, possibly
191    *            wrapping another exception.
192    */
193    virtual void endDocument () = 0;
194
195  /**
196    * Receive notification of the end of an element.
197    *
198    * <p>The SAX parser will invoke this method at the end of every
199    * element in the XML document; there will be a corresponding
200    * startElement() event for every endElement() event (even when the
201    * element is empty).</p>
202    *
203    * <p>If the element name has a namespace prefix, the prefix will
204    * still be attached to the name.</p>
205    *
206    * @param name The element type name
207    * @exception SAXException Any SAX exception, possibly
208    *            wrapping another exception.
209    */
210    virtual void endElement(const XMLCh* const name) = 0;
211
212  /**
213    * Receive notification of ignorable whitespace in element content.
214    *
215    * <p>Validating Parsers must use this method to report each chunk
216    * of ignorable whitespace (see the W3C XML 1.0 recommendation,
217    * section 2.10): non-validating parsers may also use this method
218    * if they are capable of parsing and using content models.</p>
219    *
220    * <p>SAX parsers may return all contiguous whitespace in a single
221    * chunk, or they may split it into several chunks; however, all of
222    * the characters in any single event must come from the same
223    * external entity, so that the Locator provides useful
224    * information.</p>
225    *
226    * <p>The application must not attempt to read from the array
227    * outside of the specified range.</p>
228    *
229    * @param chars The characters from the XML document.
230    * @param length The number of characters to read from the array.
231    * @exception SAXException Any SAX exception, possibly
232    *            wrapping another exception.
233    * @see #characters
234    */
235    virtual void ignorableWhitespace
236    (
237        const   XMLCh* const    chars
238        , const unsigned int    length
239    ) = 0;
240
241  /**
242    * Receive notification of a processing instruction.
243    *
244    * <p>The Parser will invoke this method once for each processing
245    * instruction found: note that processing instructions may occur
246    * before or after the main document element.</p>
247    *
248    * <p>A SAX parser should never report an XML declaration (XML 1.0,
249    * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
250    * using this method.</p>
251    *
252    * @param target The processing instruction target.
253    * @param data The processing instruction data, or null if
254    *        none was supplied.
255    * @exception SAXException Any SAX exception, possibly
256    *            wrapping another exception.
257    */
258    virtual void processingInstruction
259    (
260        const   XMLCh* const    target
261        , const XMLCh* const    data
262    ) = 0;
263
264    /**
265    * Reset the Docuemnt object on its reuse
266    *
267    * <p>This method helps in reseting the document implementational
268    * defaults each time the document is begun.</p>
269    *
270    */
271    virtual void resetDocument() = 0;
272
273  /**
274    * Receive an object for locating the origin of SAX document events.
275    *
276    * SAX parsers are strongly encouraged (though not absolutely
277    * required) to supply a locator: if it does so, it must supply
278    * the locator to the application by invoking this method before
279    * invoking any of the other methods in the DocumentHandler
280    * interface.
281    *
282    * The locator allows the application to determine the end
283    * position of any document-related event, even if the parser is
284    * not reporting an error.  Typically, the application will
285    * use this information for reporting its own errors (such as
286    * character content that does not match an application's
287    * business rules). The information returned by the locator
288    * is probably not sufficient for use with a search engine.
289    *
290    * Note that the locator will return correct information only
291    * during the invocation of the events in this interface. The
292    * application should not attempt to use it at any other time.
293    *
294    * @param locator An object that can return the location of
295    *                any SAX document event. The object is only
296    *                'on loan' to the client code and they are not
297    *                to attempt to delete or modify it in any way!
298    *
299    * @see Locator#Locator
300    */
301    virtual void setDocumentLocator(const Locator* const locator) = 0;
302
303  /**
304    * Receive notification of the beginning of a document.
305    *
306    * <p>The SAX parser will invoke this method only once, before any
307    * other methods in this interface or in DTDHandler (except for
308    * setDocumentLocator).</p>
309    *
310    * @exception SAXException Any SAX exception, possibly
311    *            wrapping another exception.
312    */
313    virtual void startDocument() = 0;
314
315  /**
316    * Receive notification of the beginning of an element.
317    *
318    * <p>The Parser will invoke this method at the beginning of every
319    * element in the XML document; there will be a corresponding
320    * endElement() event for every startElement() event (even when the
321    * element is empty). All of the element's content will be
322    * reported, in order, before the corresponding endElement()
323    * event.</p>
324    *
325    * <p>If the element name has a namespace prefix, the prefix will
326    * still be attached.  Note that the attribute list provided will
327    * contain only attributes with explicit values (specified or
328    * defaulted): #IMPLIED attributes will be omitted.</p>
329    *
330    * @param name The element type name.
331    * @param attrs The attributes attached to the element, if any.
332    * @exception SAXException Any SAX exception, possibly
333    *            wrapping another exception.
334    * @see #endElement
335    * @see AttributeList#AttributeList
336    */
337    virtual void startElement
338    (
339        const   XMLCh* const    name
340        ,       AttributeList&  attrs
341    ) = 0;
342
343    //@}
344
345private :
346    /* Unimplemented Constructors and operators */
347    /* Copy constructor */
348    DocumentHandler(const DocumentHandler&);
349    /** Assignment operator */
350    DocumentHandler& operator=(const DocumentHandler&);
351};
352
353XERCES_CPP_NAMESPACE_END
354
355#endif
Note: See TracBrowser for help on using the repository browser.