source: NonGTP/Xerces/xercesc/framework/XMLDocumentHandler.hpp @ 188

Revision 188, 15.6 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: XMLDocumentHandler.hpp,v $
59  * Revision 1.7  2004/01/29 11:46:29  cargilld
60  * Code cleanup changes to get rid of various compiler diagnostic messages.
61  *
62  * Revision 1.6  2003/11/28 05:14:34  neilg
63  * update XMLDocumentHandler to enable stateless passing of type information for elements.  Note that this is as yet unimplemented.
64  *
65  * Revision 1.5  2003/03/07 18:08:10  tng
66  * Return a reference instead of void for operator=
67  *
68  * Revision 1.4  2002/11/04 15:00:21  tng
69  * C++ Namespace Support.
70  *
71  * Revision 1.3  2002/05/28 20:41:11  tng
72  * [Bug 9104] prefixes dissapearing when schema validation turned on.
73  *
74  * Revision 1.2  2002/02/20 18:17:01  tng
75  * [Bug 5977] Warnings on generating apiDocs.
76  *
77  * Revision 1.1.1.1  2002/02/01 22:21:51  peiyongz
78  * sane_include
79  *
80  * Revision 1.8  2000/03/02 19:54:24  roddey
81  * This checkin includes many changes done while waiting for the
82  * 1.1.0 code to be finished. I can't list them all here, but a list is
83  * available elsewhere.
84  *
85  * Revision 1.7  2000/02/24 20:00:23  abagchi
86  * Swat for removing Log from API docs
87  *
88  * Revision 1.6  2000/02/16 20:29:20  aruna1
89  * API Doc++ summary changes in
90  *
91  * Revision 1.5  2000/02/16 19:48:56  roddey
92  * More documentation updates
93  *
94  * Revision 1.4  2000/02/15 01:21:30  roddey
95  * Some initial documentation improvements. More to come...
96  *
97  * Revision 1.3  2000/02/09 19:47:27  abagchi
98  * Added docs for startElement
99  *
100  * Revision 1.2  2000/02/06 07:47:48  rahulj
101  * Year 2K copyright swat.
102  *
103  * Revision 1.1.1.1  1999/11/09 01:08:31  twl
104  * Initial checkin
105  *
106  * Revision 1.3  1999/11/08 20:44:37  rahul
107  * Swat for adding in Product name and CVS comment log variable.
108  *
109  */
110
111
112#if !defined(XMLDOCUMENTHANDLER_HPP)
113#define XMLDOCUMENTHANDLER_HPP
114
115#include <xercesc/util/XercesDefs.hpp>
116#include <xercesc/util/RefVectorOf.hpp>
117#include <xercesc/framework/XMLAttr.hpp>
118
119XERCES_CPP_NAMESPACE_BEGIN
120
121class XMLElementDecl;
122class XMLEntityDecl;
123
124/**
125  * This abstract class provides the interface for the scanner to return
126  * XML document information up to the parser as it scans through the
127  * document.
128  *
129  * The interface is very similar to org.sax.DocumentHandler, but
130  * has some extra methods required to get all the data out.
131  */
132class XMLPARSER_EXPORT XMLDocumentHandler
133{
134public:
135    // -----------------------------------------------------------------------
136    //  Constructors are hidden, just the virtual destructor is exposed
137    // -----------------------------------------------------------------------
138    /** @name Destructor */
139    //@{
140    virtual ~XMLDocumentHandler()
141    {
142    }
143    //@}
144
145    /** @name The document handler interface */
146    //@{
147    /** Receive notification of character data.
148      *
149      * <p>The scanner will call this method to report each chunk of
150      * character data. The scanner may return all contiguous character
151      * data in a single chunk, or they may split it into several
152      * chunks; however, all of the characters in any single event
153      * will come from the same external entity, so that the Locator
154      * provides useful information.</p>
155      *
156      * <p>The parser must not attempt to read from the array
157      * outside of the specified range.</p>
158      *
159      * @param  chars           The content (characters) between markup from the XML
160      *                         document.
161      * @param  length          The number of characters to read from the array.
162      * @param  cdataSection    Indicates that this data is inside a CDATA
163      *                         section.
164      * @see #ignorableWhitespace
165      * @see Locator
166      */
167    virtual void docCharacters
168    (
169        const   XMLCh* const    chars
170        , const unsigned int    length
171        , const bool            cdataSection
172    ) = 0;
173
174    /** Receive notification of comments in the XML content being parsed.
175      *
176      * This scanner will call this method for any comments found in the
177      * content of the document.
178      *
179      * @param comment The text of the comment.
180      */
181    virtual void docComment
182    (
183        const   XMLCh* const    comment
184    ) = 0;
185
186    /** Receive notification of PI's parsed in the XML content.
187      *
188      * The scanner will call this method for any PIs it finds within the
189      * content of the document.
190      *
191      * @param  target  The name of the PI.
192      * @param  data    The body of the PI. This may be an empty string since
193      *                 the body is optional.
194      */
195    virtual void docPI
196    (
197        const   XMLCh* const    target
198        , const XMLCh* const    data
199    ) = 0;
200
201    /** Receive notification after the scanner has parsed the end of the
202      * document.
203      *
204      * The scanner will call this method when the current document has been
205      * fully parsed. The handler may use this opportunity to do something with
206      * the data, clean up temporary data, etc...
207      */
208    virtual void endDocument() = 0;
209
210    /** Receive notification of the end of an element.
211      *
212      * This method is called when scanner encounters the end of element tag.
213      * There will be a corresponding startElement() event for every
214      * endElement() event, but not necessarily the other way around. For
215      * empty tags, there is only a startElement() call.
216      *
217      * @param  elemDecl The name of the element whose end tag was just
218      *                     parsed.
219      * @param  uriId       The ID of the URI in the URI pool (only valid if
220      *                     name spaces is enabled)
221      * @param  isRoot      Indicates if this is the root element.
222      * @param  prefixName  The string representing the prefix name
223      */
224    virtual void endElement
225    (
226        const   XMLElementDecl& elemDecl
227        , const unsigned int    uriId
228        , const bool            isRoot
229        , const XMLCh* const    prefixName = 0
230    ) = 0;
231
232    /** Receive notification when a referenced entity's content ends
233      *
234      * This method is called when scanner encounters the end of an entity
235      * reference.
236      *
237      * @param  entDecl  The name of the entity reference just scanned.
238      */
239    virtual void endEntityReference
240    (
241        const   XMLEntityDecl&  entDecl
242    ) = 0;
243
244    /** Receive notification of ignorable whitespace in element content.
245      *
246      * <p>Validating Parsers must use this method to report each chunk
247      * of ignorable whitespace (see the W3C XML 1.0 recommendation,
248      * section 2.10): non-validating parsers may also use this method
249      * if they are capable of parsing and using content models.</p>
250      *
251      * <p>The scanner may return all contiguous whitespace in a single
252      * chunk, or it may split it into several chunks; however, all of
253      * the characters in any single event will come from the same
254      * external entity, so that the Locator provides useful
255      * information.</p>
256      *
257      * <p>The parser must not attempt to read from the array
258      * outside of the specified range.</p>
259      *
260      * @param  chars       The whitespace characters from the XML document.
261      * @param  length      The number of characters to read from the array.
262      * @param  cdataSection Indicates that this data is inside a CDATA
263      *                     section.
264      * @see #characters
265      */
266    virtual void ignorableWhitespace
267    (
268        const   XMLCh* const    chars
269        , const unsigned int    length
270        , const bool            cdataSection
271    ) = 0;
272
273    /** Reset the document handler's state, if required
274      *
275      * This method is used to give the registered document handler a
276      * chance to reset itself. Its called by the scanner at the start of
277      * every parse.
278      */
279    virtual void resetDocument() = 0;
280
281    /** Receive notification of the start of a new document
282      *
283      * This method is the first callback called the scanner at the
284      * start of every parse. This is before any content is parsed.
285      */
286    virtual void startDocument() = 0;
287
288    /** Receive notification of a new start tag
289      *
290      * This method is called when scanner encounters the start of an element tag.
291      * All elements must always have a startElement() tag. Empty tags will
292      * only have the startElement() tag and no endElement() tag.
293      *
294      * @param  elemDecl The name of the element whose start tag was just
295      *                     parsed.
296      * @param  uriId       The ID of the URI in the URI pool (only valid if
297      *                     name spaces is enabled)
298      * @param  prefixName  The string representing the prefix name
299      * @param  attrList    List of attributes in the element
300      * @param  attrCount   Count of the attributes in the element
301      * @param  isEmpty     Indicates if the element is empty, in which case
302      *                     you should not expect an endElement() event.
303      * @param  isRoot      Indicates if this is the root element.
304      */
305    virtual void startElement
306    (
307        const   XMLElementDecl&         elemDecl
308        , const unsigned int            uriId
309        , const XMLCh* const            prefixName
310        , const RefVectorOf<XMLAttr>&   attrList
311        , const unsigned int            attrCount
312        , const bool                    isEmpty
313        , const bool                    isRoot
314    ) = 0;
315
316    /** Receive notification when the scanner hits an entity reference.
317      *
318      * This is currently useful only to DOM parser configurations as SAX
319      * does not provide any api to return this information.
320      *
321      * @param  entDecl  The name of the entity that was referenced.
322      */
323    virtual void startEntityReference(const XMLEntityDecl& entDecl) = 0;
324
325    /** Receive notification of an XML declaration
326      *
327      * Currently neither DOM nor SAX provide API's to return back this
328      * information.
329      *
330      * @param  versionStr      The value of the <code>version</code> pseudoattribute
331      *                         of the XML decl.
332      * @param  encodingStr     The value of the <code>encoding</code> pseudoattribute
333      *                         of the XML decl.
334      * @param  standaloneStr   The value of the <code>standalone</code>
335      *                         pseudoattribute of the XML decl.
336      * @param  autoEncodingStr The encoding string auto-detected by the
337      *                         scanner. In absence of any 'encoding' attribute in the
338      *                         XML decl, the XML standard specifies how a parser can
339      *                         auto-detect. If there is no <code>encodingStr</code>
340      *                         this is what will be used to try to decode the file.
341      */
342    virtual void XMLDecl
343    (
344        const   XMLCh* const    versionStr
345        , const XMLCh* const    encodingStr
346        , const XMLCh* const    standaloneStr
347        , const XMLCh* const    autoEncodingStr
348    ) = 0;
349
350    /** Receive notification of the name and namespace of the type that validated
351      * the element corresponding to the most recent endElement event.
352      * This event will be fired immediately after the
353      * endElement() event that signifies the end of the element
354      * to which it applies; no other events will intervene.
355      * This method is <emEXPERIMENTAL</em> and may change, disappear
356      * or become pure virtual at any time.
357      *
358      * This corresponds to a part of the information required by DOM Core
359      * level 3's TypeInfo interface.
360      *
361      * @param  typeName        local name of the type that actually validated
362      *                         the content of the element corresponding to the
363      *                         most recent endElement() callback
364      * @param  typeURI         namespace of the type that actually validated
365      *                         the content of the element corresponding to the
366      *                         most recent endElement() callback
367      * @experimental
368      */
369    virtual void elementTypeInfo
370    (
371        const   XMLCh* const
372        , const XMLCh* const
373    ) { /* non pure virtual to permit backward compatibility of implementations.  */  };
374    //@}
375
376
377
378protected :
379    // -----------------------------------------------------------------------
380    //  Hidden Constructors
381    // -----------------------------------------------------------------------
382    XMLDocumentHandler()
383    {
384    }
385
386
387private:
388    // -----------------------------------------------------------------------
389    //  Unimplemented constructors and operators
390    // -----------------------------------------------------------------------
391    XMLDocumentHandler(const XMLDocumentHandler&);
392    XMLDocumentHandler& operator=(const XMLDocumentHandler&);
393};
394
395XERCES_CPP_NAMESPACE_END
396
397#endif
Note: See TracBrowser for help on using the repository browser.