source: NonGTP/Xerces/xerces/include/xercesc/framework/XMLDocumentHandler.hpp @ 358

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

xerces added

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