source: NonGTP/Xerces/xercesc/sax2/ContentHandler.hpp @ 188

Revision 188, 15.5 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: ContentHandler.hpp,v $
59 * Revision 1.3  2003/03/07 18:10:30  tng
60 * Return a reference instead of void for operator=
61 *
62 * Revision 1.2  2002/11/04 14:55:45  tng
63 * C++ Namespace Support.
64 *
65 * Revision 1.1.1.1  2002/02/01 22:22:09  peiyongz
66 * sane_include
67 *
68 * Revision 1.4  2000/12/14 18:50:05  tng
69 * Fix API document generation warning: "Warning: end of member group without matching begin"
70 *
71 * Revision 1.3  2000/08/09 22:19:29  jpolast
72 * many conformance & stability changes:
73 *   - ContentHandler::resetDocument() removed
74 *   - attrs param of ContentHandler::startDocument() made const
75 *   - SAXExceptions thrown now have msgs
76 *   - removed duplicate function signatures that had 'const'
77 *       [ eg: getContentHander() ]
78 *   - changed getFeature and getProperty to apply to const objs
79 *   - setProperty now takes a void* instead of const void*
80 *   - SAX2XMLReaderImpl does not inherit from SAXParser anymore
81 *   - Reuse Validator (http://apache.org/xml/features/reuse-validator) implemented
82 *   - Features & Properties now read-only during parse
83 *
84 * Revision 1.2  2000/08/07 18:21:27  jpolast
85 * change SAX_EXPORT module to SAX2_EXPORT
86 *
87 * Revision 1.1  2000/08/02 18:02:34  jpolast
88 * initial checkin of sax2 implementation
89 * submitted by Simon Fell (simon@fell.com)
90 * and Joe Polastre (jpolast@apache.org)
91 *
92 *
93 */
94
95
96#ifndef CONTENTHANDLER_HPP
97#define CONTENTHANDLER_HPP
98
99#include <xercesc/util/XercesDefs.hpp>
100
101XERCES_CPP_NAMESPACE_BEGIN
102
103class Attributes;
104class Locator;
105
106/**
107  * Receive notification of general document events.
108  *
109  * <p>This is the main interface that most SAX2 applications
110  * implement: if the application needs to be informed of basic parsing
111  * events, it implements this interface and registers an instance with
112  * the SAX2 parser using the setDocumentHandler method.  The parser
113  * uses the instance to report basic document-related events like
114  * the start and end of elements and character data.</p>
115  *
116  * <p>The order of events in this interface is very important, and
117  * mirrors the order of information in the document itself.  For
118  * example, all of an element's content (character data, processing
119  * instructions, and/or subelements) will appear, in order, between
120  * the startElement event and the corresponding endElement event.</p>
121  *
122  * <p>Application writers who do not want to implement the entire
123  * interface while can derive a class from Sax2HandlerBase, which implements
124  * the default functionality; parser writers can instantiate
125  * Sax2HandlerBase to obtain a default handler.  The application can find
126  * the location of any document event using the Locator interface
127  * supplied by the Parser through the setDocumentLocator method.</p>
128  *
129  * @see Parser#setDocumentHandler
130  * @see Locator#Locator
131  * @see Sax2HandlerBase#Sax2HandlerBase
132  */
133
134class SAX2_EXPORT ContentHandler
135{
136public:
137    /** @name Constructors and Destructor */
138    //@{
139    /** Default constructor */
140    ContentHandler()
141    {
142    }
143
144    /** Destructor */
145    virtual ~ContentHandler()
146    {
147    }
148    //@}
149
150    /** @name The virtual document handler interface */
151
152    //@{
153   /**
154    * Receive notification of character data.
155    *
156    * <p>The Parser will call this method to report each chunk of
157    * character data.  SAX parsers may return all contiguous character
158    * data in a single chunk, or they may split it into several
159    * chunks; however, all of the characters in any single event
160    * must come from the same external entity, so that the Locator
161    * provides useful information.</p>
162    *
163    * <p>The application must not attempt to read from the array
164    * outside of the specified range.</p>
165    *
166    * <p>Note that some parsers will report whitespace using the
167    * ignorableWhitespace() method rather than this one (validating
168    * parsers must do so).</p>
169    *
170    * @param chars The characters from the XML document.
171    * @param length The number of characters to read from the array.
172    * @exception SAXException Any SAX exception, possibly
173    *            wrapping another exception.
174    * @see #ignorableWhitespace
175    * @see Locator#Locator
176    */
177    virtual void characters
178    (
179        const   XMLCh* const    chars
180        , const unsigned int    length
181    ) = 0;
182
183  /**
184    * Receive notification of the end of a document.
185    *
186    * <p>The SAX parser will invoke this method only once, and it will
187    * be the last method invoked during the parse.  The parser shall
188    * not invoke this method until it has either abandoned parsing
189    * (because of an unrecoverable error) or reached the end of
190    * input.</p>
191    *
192    * @exception SAXException Any SAX exception, possibly
193    *            wrapping another exception.
194    */
195    virtual void endDocument () = 0;
196
197  /**
198    * Receive notification of the end of an element.
199    *
200    * <p>The SAX parser will invoke this method at the end of every
201    * element in the XML document; there will be a corresponding
202    * startElement() event for every endElement() event (even when the
203    * element is empty).</p>
204    *
205    * @param uri The URI of the asscioated namespace for this element
206        * @param localname The local part of the element name
207        * @param qname The QName of this element
208    * @exception SAXException Any SAX exception, possibly
209    *            wrapping another exception.
210    */
211    virtual void endElement
212        (
213                const XMLCh* const uri,
214                const XMLCh* const localname,
215                const XMLCh* const qname
216        ) = 0;
217
218  /**
219    * Receive notification of ignorable whitespace in element content.
220    *
221    * <p>Validating Parsers must use this method to report each chunk
222    * of ignorable whitespace (see the W3C XML 1.0 recommendation,
223    * section 2.10): non-validating parsers may also use this method
224    * if they are capable of parsing and using content models.</p>
225    *
226    * <p>SAX parsers may return all contiguous whitespace in a single
227    * chunk, or they may split it into several chunks; however, all of
228    * the characters in any single event must come from the same
229    * external entity, so that the Locator provides useful
230    * information.</p>
231    *
232    * <p>The application must not attempt to read from the array
233    * outside of the specified range.</p>
234    *
235    * @param chars The characters from the XML document.
236    * @param length The number of characters to read from the array.
237    * @exception SAXException Any SAX exception, possibly
238    *            wrapping another exception.
239    * @see #characters
240    */
241    virtual void ignorableWhitespace
242    (
243        const   XMLCh* const    chars
244        , const unsigned int    length
245    ) = 0;
246
247  /**
248    * Receive notification of a processing instruction.
249    *
250    * <p>The Parser will invoke this method once for each processing
251    * instruction found: note that processing instructions may occur
252    * before or after the main document element.</p>
253    *
254    * <p>A SAX parser should never report an XML declaration (XML 1.0,
255    * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
256    * using this method.</p>
257    *
258    * @param target The processing instruction target.
259    * @param data The processing instruction data, or null if
260    *        none was supplied.
261    * @exception SAXException Any SAX exception, possibly
262    *            wrapping another exception.
263    */
264    virtual void processingInstruction
265    (
266        const   XMLCh* const    target
267        , const XMLCh* const    data
268    ) = 0;
269
270  /**
271    * Receive an object for locating the origin of SAX document events.
272    *
273    * SAX parsers are strongly encouraged (though not absolutely
274    * required) to supply a locator: if it does so, it must supply
275    * the locator to the application by invoking this method before
276    * invoking any of the other methods in the DocumentHandler
277    * interface.
278    *
279    * The locator allows the application to determine the end
280    * position of any document-related event, even if the parser is
281    * not reporting an error.  Typically, the application will
282    * use this information for reporting its own errors (such as
283    * character content that does not match an application's
284    * business rules). The information returned by the locator
285    * is probably not sufficient for use with a search engine.
286    *
287    * Note that the locator will return correct information only
288    * during the invocation of the events in this interface. The
289    * application should not attempt to use it at any other time.
290    *
291    * @param locator An object that can return the location of
292    *                any SAX document event. The object is only
293    *                'on loan' to the client code and they are not
294    *                to attempt to delete or modify it in any way!
295    *
296    * @see Locator#Locator
297    */
298    virtual void setDocumentLocator(const Locator* const locator) = 0;
299
300  /**
301    * Receive notification of the beginning of a document.
302    *
303    * <p>The SAX parser will invoke this method only once, before any
304    * other methods in this interface or in DTDHandler (except for
305    * setDocumentLocator).</p>
306    *
307    * @exception SAXException Any SAX exception, possibly
308    *            wrapping another exception.
309    */
310    virtual void startDocument() = 0;
311
312  /**
313    * Receive notification of the beginning of an element.
314    *
315    * <p>The Parser will invoke this method at the beginning of every
316    * element in the XML document; there will be a corresponding
317    * endElement() event for every startElement() event (even when the
318    * element is empty). All of the element's content will be
319    * reported, in order, before the corresponding endElement()
320    * event.</p>
321    *
322    * <p>Note that the attribute list provided will
323    * contain only attributes with explicit values (specified or
324    * defaulted): #IMPLIED attributes will be omitted.</p>
325    *
326    * @param uri The URI of the asscioated namespace for this element
327        * @param localname The local part of the element name
328        * @param qname The QName of this element
329    * @param attrs The attributes attached to the element, if any.
330    * @exception SAXException Any SAX exception, possibly
331    *            wrapping another exception.
332    * @see #endElement
333    * @see Attributes#Attributes
334    */
335    virtual void startElement
336    (
337        const   XMLCh* const    uri,
338        const   XMLCh* const    localname,
339        const   XMLCh* const    qname,
340        const   Attributes&     attrs
341    ) = 0;
342
343  /**
344    * Receive notification of the start of an namespace prefix mapping.
345    *
346    * <p>By default, do nothing.  Application writers may override this
347    * method in a subclass to take specific actions at the start of
348    * each namespace prefix mapping.</p>
349    *
350    * @param prefix The namespace prefix used
351    * @param uri The namespace URI used.
352    * @exception SAXException Any SAX exception, possibly
353    *            wrapping another exception.
354    */
355        virtual void startPrefixMapping
356        (
357                const   XMLCh* const    prefix,
358                const   XMLCh* const    uri
359        ) = 0 ;
360
361  /**
362    * Receive notification of the end of an namespace prefix mapping.
363    *
364    * <p>By default, do nothing.  Application writers may override this
365    * method in a subclass to take specific actions at the end of
366    * each namespace prefix mapping.</p>
367    *
368    * @param prefix The namespace prefix used
369    * @exception SAXException Any SAX exception, possibly
370    *            wrapping another exception.
371    */
372        virtual void endPrefixMapping
373        (
374                const   XMLCh* const    prefix
375        ) = 0 ;
376
377  /**
378    * Receive notification of a skipped entity
379    *
380    * <p>The parser will invoke this method once for each entity
381        * skipped.  All processors may skip external entities,
382        * depending on the values of the features:<br>
383        * http://xml.org/sax/features/external-general-entities<br>
384        * http://xml.org/sax/features/external-parameter-entities</p>
385        *
386        * <p>Note: Xerces (specifically) never skips any entities, regardless
387        * of the above features.  This function is never called in the
388        * Xerces implementation of SAX2.</p>
389    *
390        * <p>Introduced with SAX2</p>
391        *
392    * @param name The name of the skipped entity.  If it is a parameter entity,
393        * the name will begin with %, and if it is the external DTD subset,
394        * it will be the string [dtd].
395    * @exception SAXException Any SAX exception, possibly
396    *            wrapping another exception.
397    */
398        virtual void skippedEntity
399        (
400                const   XMLCh* const    name
401        ) = 0 ;
402
403    //@}
404private :
405    /* Unimplemented Constructors and operators */
406    /* Copy constructor */
407    ContentHandler(const ContentHandler&);
408    /** Assignment operator */
409    ContentHandler& operator=(const ContentHandler&);
410};
411
412XERCES_CPP_NAMESPACE_END
413
414#endif
Note: See TracBrowser for help on using the repository browser.