source: NonGTP/Xerces/xercesc/internal/XMLScanner.hpp @ 188

Revision 188, 51.8 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-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) 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: XMLScanner.hpp,v $
59 * Revision 1.32  2003/12/31 15:40:00  cargilld
60 * Release memory when an error is encountered.
61 *
62 * Revision 1.31  2003/11/28 21:18:32  knoaman
63 * Make use of canonical representation in PSVIElement
64 *
65 * Revision 1.30  2003/11/28 19:54:31  knoaman
66 * PSVIElement update
67 *
68 * Revision 1.29  2003/11/27 22:52:37  knoaman
69 * PSVIElement implementation
70 *
71 * Revision 1.28  2003/11/24 05:09:38  neilg
72 * implement new, statless, method for detecting duplicate attributes
73 *
74 * Revision 1.27  2003/11/13 15:00:44  peiyongz
75 * Solve Compilation/Linkage error on AIX/Solaris/HP/Linux
76 *
77 * Revision 1.26  2003/11/12 20:29:47  peiyongz
78 * Stateless Grammar: ValidationContext
79 *
80 * Revision 1.25  2003/11/06 15:30:06  neilg
81 * first part of PSVI/schema component model implementation, thanks to David Cargill.  This covers setting the PSVIHandler on parser objects, as well as implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and XSAttributeUse.
82 *
83 * Revision 1.24  2003/10/22 20:22:30  knoaman
84 * Prepare for annotation support.
85 *
86 * Revision 1.23  2003/07/10 19:47:24  peiyongz
87 * Stateless Grammar: Initialize scanner with grammarResolver,
88 *                                creating grammar through grammarPool
89 *
90 * Revision 1.22  2003/05/16 21:36:58  knoaman
91 * Memory manager implementation: Modify constructors to pass in the memory manager.
92 *
93 * Revision 1.21  2003/05/15 18:26:29  knoaman
94 * Partial implementation of the configurable memory manager.
95 *
96 * Revision 1.20  2003/04/22 14:52:37  knoaman
97 * Initialize security manager in constructor.
98 *
99 * Revision 1.19  2003/04/17 22:00:46  neilg
100 * This commit implements detection of exponential entity
101 * expansions inside the scanner code.  This is only done when a
102 * security manager instance has been registered with the parser by
103 * the application.  The default number of entities which may be
104 * expanded is 50000; this appears to work very well for SAX, but DOM
105 * parsing applications may wish to set this limit considerably lower.
106 *
107 * Added SecurityManager to enable detection of exponentially-expanding entities
108 *
109 * Revision 1.18  2003/03/10 15:27:29  tng
110 * XML1.0 Errata E38
111 *
112 * Revision 1.17  2003/03/07 18:08:58  tng
113 * Return a reference instead of void for operator=
114 *
115 * Revision 1.16  2003/01/03 20:08:40  tng
116 * New feature StandardUriConformant to force strict standard uri conformance.
117 *
118 * Revision 1.15  2002/12/27 16:16:51  knoaman
119 * Set scanner options and handlers.
120 *
121 * Revision 1.14  2002/12/20 22:09:56  tng
122 * XML 1.1
123 *
124 * Revision 1.13  2002/12/04 01:41:14  knoaman
125 * Scanner re-organization.
126 *
127 * Revision 1.12  2002/11/04 14:58:19  tng
128 * C++ Namespace Support.
129 *
130 * Revision 1.11  2002/08/27 05:56:39  knoaman
131 * Identity Constraint: handle case of recursive elements.
132 *
133 * Revision 1.10  2002/08/16 15:46:17  knoaman
134 * Bug 7698 : filenames with embedded spaces in schemaLocation strings not handled properly.
135 *
136 * Revision 1.9  2002/07/31 18:49:29  tng
137 * [Bug 6227] Make method getLastExtLocation() constant.
138 *
139 * Revision 1.8  2002/07/11 18:22:13  knoaman
140 * Grammar caching/preparsing - initial implementation.
141 *
142 * Revision 1.7  2002/06/17 16:13:01  tng
143 * DOM L3: Add the flag fNormalizeData so that datatype normalization defined by schema is done only if asked.
144 *
145 * Revision 1.6  2002/06/07 18:35:49  tng
146 * Add getReaderMgr in XMLScanner so that the parser can query encoding information.
147 *
148 * Revision 1.5  2002/05/30 16:20:57  tng
149 * Add feature to optionally ignore external DTD.
150 *
151 * Revision 1.4  2002/05/27 18:42:14  tng
152 * To get ready for 64 bit large file, use XMLSSize_t to represent line and column number.
153 *
154 * Revision 1.3  2002/05/22 20:54:33  knoaman
155 * Prepare for DOM L3 :
156 * - Make use of the XMLEntityHandler/XMLErrorReporter interfaces, instead of using
157 * EntityHandler/ErrorHandler directly.
158 * - Add 'AbstractDOMParser' class to provide common functionality for XercesDOMParser
159 * and DOMBuilder.
160 *
161 * Revision 1.2  2002/03/25 20:25:32  knoaman
162 * Move particle derivation checking from TraverseSchema to SchemaValidator.
163 *
164 * Revision 1.1.1.1  2002/02/01 22:22:03  peiyongz
165 * sane_include
166 *
167 * Revision 1.38  2001/11/30 22:19:15  peiyongz
168 * cleanUp function made member function
169 * cleanUp object moved to file scope
170 *
171 * Revision 1.37  2001/11/20 18:51:44  tng
172 * Schema: schemaLocation and noNamespaceSchemaLocation to be specified outside the instance document.  New methods setExternalSchemaLocation and setExternalNoNamespaceSchemaLocation are added (for SAX2, two new properties are added).
173 *
174 * Revision 1.36  2001/11/13 13:27:28  tng
175 * Move root element check to XMLScanner.
176 *
177 * Revision 1.35  2001/11/02 14:20:14  knoaman
178 * Add support for identity constraints.
179 *
180 * Revision 1.34  2001/10/12 20:52:18  tng
181 * Schema: Find the attributes see if they should be (un)qualified.
182 *
183 * Revision 1.33  2001/09/10 15:16:04  tng
184 * Store the fGrammarType instead of calling getGrammarType all the time for faster performance.
185 *
186 * Revision 1.32  2001/09/10 14:06:22  tng
187 * Schema: AnyAttribute support in Scanner and Validator.
188 *
189 * Revision 1.31  2001/08/13 15:06:39  knoaman
190 * update <any> validation.
191 *
192 * Revision 1.30  2001/08/02 16:54:39  tng
193 * Reset some Scanner flags in scanReset().
194 *
195 * Revision 1.29  2001/08/01 19:11:01  tng
196 * Add full schema constraint checking flag to the samples and the parser.
197 *
198 * Revision 1.28  2001/07/24 21:23:39  tng
199 * Schema: Use DatatypeValidator for ID/IDREF/ENTITY/ENTITIES/NOTATION.
200 *
201 * Revision 1.27  2001/07/13 16:56:48  tng
202 * ScanId fix.
203 *
204 * Revision 1.26  2001/07/12 18:50:17  tng
205 * Some performance modification regarding standalone check and xml decl check.
206 *
207 * Revision 1.25  2001/07/10 21:09:31  tng
208 * Give proper error messsage when scanning external id.
209 *
210 * Revision 1.24  2001/07/09 13:42:08  tng
211 * Partial Markup in Parameter Entity is validity constraint and thus should be just error, not fatal error.
212 *
213 * Revision 1.23  2001/07/05 13:12:11  tng
214 * Standalone checking is validity constraint and thus should be just error, not fatal error:
215 *
216 * Revision 1.22  2001/06/22 12:42:33  tng
217 * [Bug 2257] 1.5 thinks a <?xml-stylesheet ...> tag is a <?xml ...> tag
218 *
219 * Revision 1.21  2001/06/04 20:59:29  jberry
220 * Add method incrementErrorCount for use by validator. Make sure to reset error count in _both_ the scanReset methods.
221 *
222 * Revision 1.20  2001/06/03 19:21:40  jberry
223 * Add support for tracking error count during parse; enables simple parse without requiring error handler.
224 *
225 * Revision 1.19  2001/05/28 20:55:02  tng
226 * Schema: allocate a fDTDValidator, fSchemaValidator explicitly to avoid wrong cast
227 *
228 * Revision 1.18  2001/05/11 15:17:28  tng
229 * Schema: Nillable fixes.
230 *
231 * Revision 1.17  2001/05/11 13:26:17  tng
232 * Copyright update.
233 *
234 * Revision 1.16  2001/05/03 20:34:29  tng
235 * Schema: SchemaValidator update
236 *
237 * Revision 1.15  2001/05/03 19:09:09  knoaman
238 * Support Warning/Error/FatalError messaging.
239 * Validity constraints errors are treated as errors, with the ability by user to set
240 * validity constraints as fatal errors.
241 *
242 * Revision 1.14  2001/04/19 18:16:59  tng
243 * Schema: SchemaValidator update, and use QName in Content Model
244 *
245 * Revision 1.13  2001/03/30 16:46:56  tng
246 * Schema: Use setDoSchema instead of setSchemaValidation which makes more sense.
247 *
248 * Revision 1.12  2001/03/30 16:35:06  tng
249 * Schema: Whitespace normalization.
250 *
251 * Revision 1.11  2001/03/21 21:56:05  tng
252 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar.
253 *
254 * Revision 1.10  2001/02/15 15:56:27  tng
255 * Schema: Add setSchemaValidation and getSchemaValidation for DOMParser and SAXParser.
256 * Add feature "http://apache.org/xml/features/validation/schema" for SAX2XMLReader.
257 * New data field  fSchemaValidation in XMLScanner as the flag.
258 *
259 * Revision 1.9  2000/04/12 22:58:28  roddey
260 * Added support for 'auto validate' mode.
261 *
262 * Revision 1.8  2000/03/03 01:29:32  roddey
263 * Added a scanReset()/parseReset() method to the scanner and
264 * parsers, to allow for reset after early exit from a progressive parse.
265 * Added calls to new Terminate() call to all of the samples. Improved
266 * documentation in SAX and DOM parsers.
267 *
268 * Revision 1.7  2000/03/02 19:54:30  roddey
269 * This checkin includes many changes done while waiting for the
270 * 1.1.0 code to be finished. I can't list them all here, but a list is
271 * available elsewhere.
272 *
273 * Revision 1.6  2000/02/24 20:18:07  abagchi
274 * Swat for removing Log from API docs
275 *
276 * Revision 1.5  2000/02/06 07:47:54  rahulj
277 * Year 2K copyright swat.
278 *
279 * Revision 1.4  2000/01/24 20:40:43  roddey
280 * Exposed the APIs to get to the byte offset in the source XML buffer. This stuff
281 * is not tested yet, but I wanted to get the API changes in now so that the API
282 * can be stablized.
283 *
284 * Revision 1.3  2000/01/12 23:52:46  roddey
285 * These are trivial changes required to get the C++ and Java versions
286 * of error messages more into sync. Mostly it was where the Java version
287 * was passing out one or more parameter than the C++ version was. In
288 * some cases the change just required an extra parameter to get the
289 * needed info to the place where the error was issued.
290 *
291 * Revision 1.2  2000/01/12 00:15:04  roddey
292 * Changes to deal with multiply nested, relative pathed, entities and to deal
293 * with the new URL class changes.
294 *
295 * Revision 1.1.1.1  1999/11/09 01:08:23  twl
296 * Initial checkin
297 *
298 * Revision 1.4  1999/11/08 20:44:52  rahul
299 * Swat for adding in Product name and CVS comment log variable.
300 *
301 */
302
303
304#if !defined(XMLSCANNER_HPP)
305#define XMLSCANNER_HPP
306
307#include <xercesc/framework/XMLBufferMgr.hpp>
308#include <xercesc/framework/XMLErrorCodes.hpp>
309#include <xercesc/framework/XMLRefInfo.hpp>
310#include <xercesc/util/PlatformUtils.hpp>
311#include <xercesc/util/NameIdPool.hpp>
312#include <xercesc/util/RefHashTableOf.hpp>
313#include <xercesc/util/SecurityManager.hpp>
314#include <xercesc/internal/ReaderMgr.hpp>
315#include <xercesc/internal/ElemStack.hpp>
316#include <xercesc/validators/DTD/DTDEntityDecl.hpp>
317#include <xercesc/framework/XMLAttr.hpp>
318#include <xercesc/framework/ValidationContext.hpp>
319#include <xercesc/validators/common/GrammarResolver.hpp>
320
321XERCES_CPP_NAMESPACE_BEGIN
322
323class InputSource;
324class XMLDocumentHandler;
325class XMLEntityHandler;
326class ErrorHandler;
327class DocTypeHandler;
328class XMLPScanToken;
329class XMLStringPool;
330class Grammar;
331class XMLValidator;
332class MemoryManager;
333class PSVIHandler;
334
335
336struct PSVIElemContext
337{
338    bool               fIsSpecified;
339    bool               fErrorOccurred;
340    int                fElemDepth;
341    int                fFullValidationDepth;
342    int                fNoneValidationDepth;
343    DatatypeValidator* fCurrentDV;
344    ComplexTypeInfo*   fCurrentTypeInfo;
345    const XMLCh*       fNormalizedValue;
346};
347
348//  This is the mondo scanner class, which does the vast majority of the
349//  work of parsing. It handles reading in input and spitting out events
350//  to installed handlers.
351class XMLPARSER_EXPORT XMLScanner : public XMemory
352{
353public :
354    // -----------------------------------------------------------------------
355    //  Public class types
356    //
357    //  NOTE: These should really be private, but some of the compilers we
358    //  have to deal with are too stupid to understand this.
359    //
360    //  DeclTypes
361    //      Used by scanXMLDecl() to know what type of decl it should scan.
362    //      Text decls have slightly different rules from XMLDecls.
363    //
364    //  EntityExpRes
365    //      These are the values returned from the entity expansion method,
366    //      to indicate how it went.
367    //
368    //  XMLTokens
369    //      These represent the possible types of input we can get while
370    //      scanning content.
371    //
372    //  ValScheme
373    //      This indicates what the scanner should do in terms of validation.
374    //      'Auto' means if there is any int/ext subset, then validate. Else,
375    //      don't.
376    // -----------------------------------------------------------------------
377    enum DeclTypes
378    {
379        Decl_Text
380        , Decl_XML
381    };
382
383    enum EntityExpRes
384    {
385        EntityExp_Pushed
386        , EntityExp_Returned
387        , EntityExp_Failed
388    };
389
390    enum XMLTokens
391    {
392        Token_CData
393        , Token_CharData
394        , Token_Comment
395        , Token_EndTag
396        , Token_EOF
397        , Token_PI
398        , Token_StartTag
399        , Token_Unknown
400    };
401
402    enum ValSchemes
403    {
404        Val_Never
405        , Val_Always
406        , Val_Auto
407    };
408
409
410    // -----------------------------------------------------------------------
411    //  Constructors and Destructor
412    // -----------------------------------------------------------------------
413    XMLScanner
414    (
415        XMLValidator* const valToAdopt
416        , GrammarResolver* const grammarResolver
417        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
418    );
419    XMLScanner
420    (
421        XMLDocumentHandler* const  docHandler
422        , DocTypeHandler* const    docTypeHandler
423        , XMLEntityHandler* const  entityHandler
424        , XMLErrorReporter* const  errReporter
425        , XMLValidator* const      valToAdopt
426        , GrammarResolver* const grammarResolver
427        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
428    );
429    virtual ~XMLScanner();
430
431
432    // -----------------------------------------------------------------------
433    //  Error emitter methods
434    // -----------------------------------------------------------------------
435    bool emitErrorWillThrowException(const XMLErrs::Codes toEmit);
436    void emitError(const XMLErrs::Codes toEmit);
437    void emitError
438    (
439        const   XMLErrs::Codes    toEmit
440        , const XMLCh* const        text1
441        , const XMLCh* const        text2 = 0
442        , const XMLCh* const        text3 = 0
443        , const XMLCh* const        text4 = 0
444    );
445    void emitError
446    (
447        const   XMLErrs::Codes    toEmit
448        , const char* const         text1
449        , const char* const         text2 = 0
450        , const char* const         text3 = 0
451        , const char* const         text4 = 0
452    );
453
454    // -----------------------------------------------------------------------
455    //  Public pure virtual methods
456    // -----------------------------------------------------------------------
457    virtual const XMLCh* getName() const = 0;
458    virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool() = 0;
459    virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const = 0;
460    virtual unsigned int resolveQName
461    (
462        const   XMLCh* const        qName
463        ,       XMLBuffer&          prefixBufToFill
464        , const short               mode
465        ,       int&                prefixColonPos
466    ) = 0;
467    virtual void scanDocument
468    (
469        const   InputSource&    src
470    ) = 0;
471    virtual bool scanNext(XMLPScanToken& toFill) = 0;
472    virtual Grammar* loadGrammar
473    (
474        const   InputSource&    src
475        , const short           grammarType
476        , const bool            toCache = false
477    ) = 0;
478
479    // -----------------------------------------------------------------------
480    //  Getter methods
481    // -----------------------------------------------------------------------
482    const XMLDocumentHandler* getDocHandler() const;
483    XMLDocumentHandler* getDocHandler();
484    const DocTypeHandler* getDocTypeHandler() const;
485    DocTypeHandler* getDocTypeHandler();
486    bool getDoNamespaces() const;
487    ValSchemes getValidationScheme() const;
488    bool getDoSchema() const;
489    bool getValidationSchemaFullChecking() const;
490    const XMLEntityHandler* getEntityHandler() const;
491    XMLEntityHandler* getEntityHandler();
492    const XMLErrorReporter* getErrorReporter() const;
493    XMLErrorReporter* getErrorReporter();
494    const ErrorHandler* getErrorHandler() const;
495    ErrorHandler* getErrorHandler();
496    const PSVIHandler* getPSVIHandler() const;
497    PSVIHandler* getPSVIHandler();
498    bool getExitOnFirstFatal() const;
499    bool getValidationConstraintFatal() const;
500    RefHashTableOf<XMLRefInfo>* getIDRefList();
501    const RefHashTableOf<XMLRefInfo>* getIDRefList() const;
502
503    ValidationContext*   getValidationContext();
504
505    bool getInException() const;
506    /*bool getLastExtLocation
507    (
508                XMLCh* const    sysIdToFill
509        , const unsigned int    maxSysIdChars
510        ,       XMLCh* const    pubIdToFill
511        , const unsigned int    maxPubIdChars
512        ,       XMLSSize_t&     lineToFill
513        ,       XMLSSize_t&     colToFill
514    ) const;*/
515    const Locator* getLocator() const;
516    const ReaderMgr* getReaderMgr() const;
517    unsigned int getSrcOffset() const;
518    bool getStandalone() const;
519    const XMLValidator* getValidator() const;
520    XMLValidator* getValidator();
521    int getErrorCount();
522    const XMLStringPool* getURIStringPool() const;
523    XMLStringPool* getURIStringPool();
524    bool getHasNoDTD() const;
525    XMLCh* getExternalSchemaLocation() const;
526    XMLCh* getExternalNoNamespaceSchemaLocation() const;
527    SecurityManager* getSecurityManager() const;
528    bool getLoadExternalDTD() const;
529    bool getNormalizeData() const;
530    bool isCachingGrammarFromParse() const;
531    bool isUsingCachedGrammarInParse() const;
532    bool getCalculateSrcOfs() const;
533    Grammar* getRootGrammar() const;
534    XMLReader::XMLVersion getXMLVersion() const;
535    MemoryManager* getMemoryManager() const;
536    ValueVectorOf<PrefMapElem*>* getNamespaceContext() const;
537    unsigned int getPrefixId(const XMLCh* const prefix) const;
538    const XMLCh* getPrefixForId(unsigned int prefId) const;
539
540    // -----------------------------------------------------------------------
541    //  Getter methods
542    // -----------------------------------------------------------------------
543    /**
544      * When an attribute name has no prefix, unlike elements, it is not mapped
545      * to the global namespace. So, in order to have something to map it to
546      * for practical purposes, a id for an empty URL is created and used for
547      * such names.
548      *
549      * @return The URL pool id of the URL for an empty URL "".
550      */
551    unsigned int getEmptyNamespaceId() const;
552
553    /**
554      * When a prefix is found that has not been mapped, an error is issued.
555      * However, if the parser has been instructed not to stop on the first
556      * fatal error, it needs to be able to continue. To do so, it will map
557      * that prefix tot his magic unknown namespace id.
558      *
559      * @return The URL pool id of the URL for the unknown prefix
560      *         namespace.
561      */
562    unsigned int getUnknownNamespaceId() const;
563
564    /**
565      * The prefix 'xml' is a magic prefix, defined by the XML spec and
566      * requiring no prior definition. This method returns the id for the
567      * intrinsically defined URL for this prefix.
568      *
569      * @return The URL pool id of the URL for the 'xml' prefix.
570      */
571    unsigned int getXMLNamespaceId() const;
572
573    /**
574      * The prefix 'xmlns' is a magic prefix, defined by the namespace spec
575      * and requiring no prior definition. This method returns the id for the
576      * intrinsically defined URL for this prefix.
577      *
578      * @return The URL pool id of the URL for the 'xmlns' prefix.
579      */
580    unsigned int getXMLNSNamespaceId() const;
581
582    /**
583      * This method find the passed URI id in its URI pool and
584      * copy the text of that URI into the passed buffer.
585      */
586    bool getURIText
587    (
588        const   unsigned int    uriId
589        ,       XMLBuffer&      uriBufToFill
590    )   const;
591
592    const XMLCh* getURIText(const   unsigned int    uriId) const;
593
594    /* tell if the validator comes from user */
595    bool isValidatorFromUser();
596
597    /* tell if standard URI are forced */
598    bool getStandardUriConformant() const;
599
600    // -----------------------------------------------------------------------
601    //  Setter methods
602    // -----------------------------------------------------------------------
603    void setDocHandler(XMLDocumentHandler* const docHandler);
604    void setDocTypeHandler(DocTypeHandler* const docTypeHandler);
605    void setDoNamespaces(const bool doNamespaces);
606    void setEntityHandler(XMLEntityHandler* const docTypeHandler);
607    void setErrorReporter(XMLErrorReporter* const errHandler);
608    void setErrorHandler(ErrorHandler* const handler);
609    void setPSVIHandler(PSVIHandler* const handler);
610    void setURIStringPool(XMLStringPool* const stringPool);
611    void setExitOnFirstFatal(const bool newValue);
612    void setValidationConstraintFatal(const bool newValue);
613    void setValidationScheme(const ValSchemes newScheme);
614    void setValidator(XMLValidator* const valToAdopt);
615    void setDoSchema(const bool doSchema);
616    void setValidationSchemaFullChecking(const bool schemaFullChecking);
617    void setHasNoDTD(const bool hasNoDTD);
618    void cacheGrammarFromParse(const bool newValue);
619    void useCachedGrammarInParse(const bool newValue);
620    void setRootElemName(XMLCh* rootElemName);
621    void setExternalSchemaLocation(const XMLCh* const schemaLocation);
622    void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation);
623    void setExternalSchemaLocation(const char* const schemaLocation);
624    void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation);
625    void setSecurityManager(SecurityManager* const securityManager);
626    void setLoadExternalDTD(const bool loadDTD);
627    void setNormalizeData(const bool normalizeData);
628    void setCalculateSrcOfs(const bool newValue);
629    void setParseSettings(XMLScanner* const refScanner);
630    void setStandardUriConformant(const bool newValue);
631
632    // -----------------------------------------------------------------------
633    //  Mutator methods
634    // -----------------------------------------------------------------------
635    void incrementErrorCount(void);                     // For use by XMLValidator
636
637    // -----------------------------------------------------------------------
638    //  Deprecated methods as of 3.2.0. Use getValidationScheme() and
639    //  setValidationScheme() instead.
640    // -----------------------------------------------------------------------
641    bool getDoValidation() const;
642    void setDoValidation(const bool validate);
643
644    // -----------------------------------------------------------------------
645    //  Document scanning methods
646    //
647    //  scanDocument() does the entire source document. scanFirst(),
648    //  scanNext(), and scanReset() support a progressive parse.
649    // -----------------------------------------------------------------------
650    void scanDocument
651    (
652        const   XMLCh* const    systemId
653    );
654    void scanDocument
655    (
656        const   char* const     systemId
657    );
658
659    bool scanFirst
660    (
661        const   InputSource&    src
662        ,       XMLPScanToken&  toFill
663    );
664    bool scanFirst
665    (
666        const   XMLCh* const    systemId
667        ,       XMLPScanToken&  toFill
668    );
669    bool scanFirst
670    (
671        const   char* const     systemId
672        ,       XMLPScanToken&  toFill
673    );
674
675    void scanReset(XMLPScanToken& toFill);
676
677    bool checkXMLDecl(bool startWithAngle);
678
679    // -----------------------------------------------------------------------
680    //  Grammar preparsing methods
681    // -----------------------------------------------------------------------
682    Grammar* loadGrammar
683    (
684        const   XMLCh* const    systemId
685        , const short           grammarType
686        , const bool            toCache = false
687    );
688    Grammar* loadGrammar
689    (
690        const   char* const     systemId
691        , const short           grammarType
692        , const bool            toCache = false
693    );
694
695    // -----------------------------------------------------------------------
696    //  Notification that lazy data has been deleted
697    // -----------------------------------------------------------------------
698        static void reinitScannerMutex();
699        static void reinitMsgLoader();
700
701protected:
702    // -----------------------------------------------------------------------
703    //  Protected pure virtual methods
704    // -----------------------------------------------------------------------
705    virtual void scanCDSection() = 0;
706    virtual void scanCharData(XMLBuffer& toToUse) = 0;
707    virtual EntityExpRes scanEntityRef
708    (
709        const   bool    inAttVal
710        ,       XMLCh&  firstCh
711        ,       XMLCh&  secondCh
712        ,       bool&   escaped
713    ) = 0;
714    virtual void scanDocTypeDecl() = 0;
715    virtual void scanReset(const InputSource& src) = 0;
716    virtual void sendCharData(XMLBuffer& toSend) = 0;
717
718    // -----------------------------------------------------------------------
719    //  Protected scanning methods
720    // -----------------------------------------------------------------------
721    bool scanCharRef(XMLCh& toFill, XMLCh& second);
722    void scanComment();
723    bool scanEq();
724    void scanMiscellaneous();
725    void scanPI();
726    void scanProlog();
727    void scanXMLDecl(const DeclTypes type);
728
729    // -----------------------------------------------------------------------
730    //  Private helper methods
731    // -----------------------------------------------------------------------
732    void checkIDRefs();
733    bool isLegalToken(const XMLPScanToken& toCheck);
734    XMLTokens senseNextToken(unsigned int& orgReader);
735    void initValidator(XMLValidator* theValidator);
736    inline void resetValidationContext();
737    unsigned int *getNewUIntPtr();
738    void resetUIntPool();
739    void recreateUIntPool();
740
741    // -----------------------------------------------------------------------
742    //  Data members
743    //
744    //  fAttrList
745    //      Every time we get a new element start tag, we have to pass to
746    //      the document handler the attributes found. To make it more
747    //      efficient we keep this ref vector of XMLAttr objects around. We
748    //      just reuse it over and over, allowing it to grow to meet the
749    //      peak need.
750    //
751    //  fBufMgr
752    //      This is a manager for temporary buffers used during scanning.
753    //      For efficiency we must use a set of static buffers, but we have
754    //      to insure that they are not incorrectly reused. So this manager
755    //      provides the smarts to hand out buffers as required.
756    //
757    //  fDocHandler
758    //      The client code's document handler. If zero, then no document
759    //      handler callouts are done. We don't adopt it.
760    //
761    //  fDocTypeHandler
762    //      The client code's document type handler (used by DTD Validator).
763    //
764    //  fDoNamespaces
765    //      This flag indicates whether the client code wants us to do
766    //      namespaces or not. If the installed validator indicates that it
767    //      has to do namespaces, then this is ignored.
768    //
769    //  fEntityHandler
770    //      The client code's entity handler. If zero, then no entity handler
771    //      callouts are done. We don't adopt it.
772    //
773    //  fErrorReporter
774    //      The client code's error reporter. If zero, then no error reporter
775    //      callouts are done. We don't adopt it.
776    //
777    //  fErrorHandler
778    //      The client code's error handler.  Need to store this info for
779    //      Schema parse error handling.
780    //
781    //  fPSVIHandler
782    //      The client code's PSVI handler.
783    //
784    //  fExitOnFirstFatal
785    //      This indicates whether we bail out on the first fatal XML error
786    //      or not. It defaults to true, which is the strict XML way, but it
787    //      can be changed.
788    //
789    //  fValidationConstraintFatal
790    //      This indicates whether we treat validation constraint errors as
791    //      fatal errors or not. It defaults to false, but it can be changed.
792    //
793    //  fIDRefList
794    //      This is a list of XMLRefInfo objects. This member lets us do all
795    //      needed ID-IDREF balancing checks.
796    //
797    //  fInException
798    //      To avoid a circular freakout when we catch an exception and emit
799    //      it, which would normally throw again if the 'fail on first error'
800    //      flag is one.
801    //
802    //  fReaderMgr
803    //      This is the reader manager, from which we get characters. It
804    //      manages the reader stack for us, and provides a lot of convenience
805    //      methods to do specialized checking for chars, sequences of chars,
806    //      skipping chars, etc...
807    //
808    //  fScannerId
809    //  fSequenceId
810    //      These are used for progressive parsing, to make sure that the
811    //      client code does the right thing at the right time.
812    //
813    //  fStandalone
814    //      Indicates whether the document is standalone or not. Defaults to
815    //      no, but can be overridden in the XMLDecl.
816    //
817    //  fHasNoDTD
818    //      Indicates the document has no DTD or has only an internal DTD subset
819    //      which contains no parameter entity references.
820    //
821    //  fValidate
822    //      Indicates whether any validation should be done. This is defined
823    //      by the existence of a Grammar together with fValScheme.
824    //
825    //  fValidator
826    //      The installed validator. We look at them via the abstract
827    //      validator interface, and don't know what it actual is.
828    //      Either point to user's installed validator, or fDTDValidator
829    //      or fSchemaValidator.
830    //
831    //  fValidatorFromUser
832    //      This flag indicates whether the validator was installed from
833    //      user.  If false, then the validator was created by the Scanner.
834    //
835    //  fValScheme
836    //      This is the currently set validation scheme. It defaults to
837    //      'never', but can be set by the client.
838    //
839    //  fErrorCount
840    //          The number of errors we've encountered.
841    //
842    //  fDoSchema
843    //      This flag indicates whether the client code wants Schema to
844    //      be processed or not.
845    //
846    //  fSchemaFullChecking
847    //      This flag indicates whether the client code wants full Schema
848    //      constraint checking.
849    //
850    //  fAttName
851    //  fAttValue
852    //  fCDataBuf
853    //  fNameBuf
854    //  fQNameBuf
855    //  fPrefixBuf
856    //      For the most part, buffers are obtained from the fBufMgr object
857    //      on the fly. However, for the start tag scan, we have a set of
858    //      fixed buffers for performance reasons. These are used a lot and
859    //      there are a number of them, so asking the buffer manager each
860    //      time for new buffers is a bit too much overhead.
861    //
862    //  fEmptyNamespaceId
863    //      This is the id of the empty namespace URI. This is a special one
864    //      because of the xmlns="" type of deal. We have to quickly sense
865    //      that its the empty namespace.
866    //
867    //  fUnknownNamespaceId
868    //      This is the id of the namespace URI which is assigned to the
869    //      global namespace. Its for debug purposes only, since there is no
870    //      real global namespace URI. Its set by the derived class.
871    //
872    //  fXMLNamespaceId
873    //  fXMLNSNamespaceId
874    //      These are the ids of the namespace URIs which are assigned to the
875    //      'xml' and 'xmlns' special prefixes. The former is officially
876    //      defined but the latter is not, so we just provide one for debug
877    //      purposes.
878    //
879    //  fSchemaNamespaceId
880    //      This is the id of the schema namespace URI.
881    //
882    //  fGrammarResolver
883    //      Grammar Pool that stores all the grammars. Key is namespace for
884    //      schema and system id for external DTD. When caching a grammar, if
885    //      a grammar is already in the pool, it will be replaced with the
886    //      new parsed one.
887    //
888    //  fGrammar
889    //      Current Grammar used by the Scanner and Validator
890    //
891    //  fRootGrammar
892    //      The grammar where the root element is declared.
893    //
894    //  fGrammarType
895    //      Current Grammar Type.  Store this value instead of calling getGrammarType
896    //      all the time for faster performance.
897    //
898    //  fURIStringPool
899    //      This is a pool for URIs with unique ids assigned. We use a standard
900    //      string pool class.  This pool is going to be shared by all Grammar.
901    //      Use only if namespace is turned on.
902    //
903    //  fRootElemName
904    //      No matter we are using DTD or Schema Grammar, if a DOCTYPE exists,
905    //      we need to verify the root element name.  So store the rootElement
906    //      that is used in the DOCTYPE in the Scanner instead of in the DTDGrammar
907    //      where it used to
908    //
909    //  fExternalSchemaLocation
910    //      The list of Namespace/SchemaLocation that was specified externally
911    //      using setExternalSchemaLocation.
912    //
913    //  fExternalNoNamespaceSchemaLocation
914    //      The no target namespace XML Schema Location that was specified
915    //      externally using setExternalNoNamespaceSchemaLocation.
916    //
917    //  fSecurityManager
918    //      The SecurityManager instance; as and when set by the application.
919    //
920    //  fEntityExpansionLimit
921    //      The number of entity expansions to be permitted while processing this document
922    //      Only meaningful when fSecurityManager != 0
923    //
924    //  fEntityExpansionCount
925    //      The number of general entities expanded so far in this document.
926    //      Only meaningful when fSecurityManager != null
927    //
928    //  fLoadExternalDTD
929    //      This flag indicates whether the external DTD be loaded or not
930    //
931    //  fNormalizeData
932    //      This flag indicates whether the parser should perform datatype
933    //      normalization that is defined in the schema.
934    //
935    //  fCalculateSrcOfs
936    //      This flag indicates the parser should calculate the source offset.
937    //      Turning this on may impact performance.
938    //
939    //  fStandardUriConformant
940    //      This flag controls whether we force conformant URI
941    //
942    //  fXMLVersion
943    //      Enum to indicate if the main doc is XML 1.1 or XML 1.0 conformant   
944    //  fUIntPool
945    //      pool of unsigned integers to help with duplicate attribute
946    //      detection and filling in default/fixed attributes
947    //  fUIntPoolRow
948    //      current row in fUIntPool
949    //  fUIntPoolCol
950    //      current column i row
951    //  fUIntPoolRowTotal
952    //      total number of rows in table
953    //
954    //  fMemoryManager
955    //      Pluggable memory manager for dynamic allocation/deallocation.
956    // -----------------------------------------------------------------------
957    bool                        fStandardUriConformant;
958    bool                        fCalculateSrcOfs;
959    bool                        fDoNamespaces;
960    bool                        fExitOnFirstFatal;
961    bool                        fValidationConstraintFatal;
962    bool                        fInException;
963    bool                        fStandalone;
964    bool                        fHasNoDTD;
965    bool                        fValidate;
966    bool                        fValidatorFromUser;
967    bool                        fDoSchema;
968    bool                        fSchemaFullChecking;
969    bool                        fToCacheGrammar;
970    bool                        fUseCachedGrammar;
971    bool                        fLoadExternalDTD;
972    bool                        fNormalizeData;
973    int                         fErrorCount;
974    unsigned int                fEntityExpansionLimit;
975    unsigned int                fEntityExpansionCount;
976    unsigned int                fEmptyNamespaceId;
977    unsigned int                fUnknownNamespaceId;
978    unsigned int                fXMLNamespaceId;
979    unsigned int                fXMLNSNamespaceId;
980    unsigned int                fSchemaNamespaceId;
981    unsigned int **             fUIntPool;
982    unsigned int                fUIntPoolRow;
983    unsigned int                fUIntPoolCol;
984    unsigned int                fUIntPoolRowTotal;
985    XMLUInt32                   fScannerId;
986    XMLUInt32                   fSequenceId;
987    RefVectorOf<XMLAttr>*       fAttrList;
988    XMLDocumentHandler*         fDocHandler;
989    DocTypeHandler*             fDocTypeHandler;
990    XMLEntityHandler*           fEntityHandler;
991    XMLErrorReporter*           fErrorReporter;
992    ErrorHandler*               fErrorHandler;
993    PSVIHandler*                fPSVIHandler;
994    ValidationContext           *fValidationContext;
995    bool                        fEntityDeclPoolRetrieved;
996    ReaderMgr                   fReaderMgr;
997    XMLValidator*               fValidator;
998    ValSchemes                  fValScheme;
999    GrammarResolver* const      fGrammarResolver;
1000    MemoryManager* const        fGrammarPoolMemoryManager;
1001    Grammar*                    fGrammar;
1002    Grammar*                    fRootGrammar;
1003    XMLStringPool*              fURIStringPool;
1004    XMLCh*                      fRootElemName;
1005    XMLCh*                      fExternalSchemaLocation;
1006    XMLCh*                      fExternalNoNamespaceSchemaLocation;
1007    SecurityManager*            fSecurityManager;
1008    XMLReader::XMLVersion       fXMLVersion;
1009    MemoryManager*              fMemoryManager;
1010    XMLBufferMgr                fBufMgr;
1011    XMLBuffer                   fAttNameBuf;
1012    XMLBuffer                   fAttValueBuf;
1013    XMLBuffer                   fCDataBuf;
1014    XMLBuffer                   fQNameBuf;
1015    XMLBuffer                   fPrefixBuf;
1016    XMLBuffer                   fURIBuf;
1017    ElemStack                   fElemStack;
1018
1019
1020private :
1021    // -----------------------------------------------------------------------
1022    //  Unimplemented constructors and operators
1023    // -----------------------------------------------------------------------
1024    XMLScanner();
1025    XMLScanner(const XMLScanner&);
1026    XMLScanner& operator=(const XMLScanner&);
1027
1028    // -----------------------------------------------------------------------
1029    //  Private helper methods
1030    // -----------------------------------------------------------------------
1031    void commonInit();
1032
1033    // -----------------------------------------------------------------------
1034    //  Private scanning methods
1035    // -----------------------------------------------------------------------
1036    bool getQuotedString(XMLBuffer& toFill);
1037    unsigned int scanUpToWSOr
1038    (
1039                XMLBuffer&  toFill
1040        , const XMLCh       chEndChar
1041    );
1042};
1043
1044// ---------------------------------------------------------------------------
1045//  XMLScanner: Getter methods
1046// ---------------------------------------------------------------------------
1047inline const XMLDocumentHandler* XMLScanner::getDocHandler() const
1048{
1049    return fDocHandler;
1050}
1051
1052inline XMLDocumentHandler* XMLScanner::getDocHandler()
1053{
1054    return fDocHandler;
1055}
1056
1057inline const DocTypeHandler* XMLScanner::getDocTypeHandler() const
1058{
1059    return fDocTypeHandler;
1060}
1061
1062inline DocTypeHandler* XMLScanner::getDocTypeHandler()
1063{
1064    return fDocTypeHandler;
1065}
1066
1067inline bool XMLScanner::getDoNamespaces() const
1068{
1069    return fDoNamespaces;
1070}
1071
1072inline const XMLEntityHandler* XMLScanner::getEntityHandler() const
1073{
1074    return fEntityHandler;
1075}
1076
1077inline XMLEntityHandler* XMLScanner::getEntityHandler()
1078{
1079    return fEntityHandler;
1080}
1081
1082inline const XMLErrorReporter* XMLScanner::getErrorReporter() const
1083{
1084    return fErrorReporter;
1085}
1086
1087inline XMLErrorReporter* XMLScanner::getErrorReporter()
1088{
1089    return fErrorReporter;
1090}
1091
1092inline const ErrorHandler* XMLScanner::getErrorHandler() const
1093{
1094    return fErrorHandler;
1095}
1096
1097inline ErrorHandler* XMLScanner::getErrorHandler()
1098{
1099    return fErrorHandler;
1100}
1101
1102inline const PSVIHandler* XMLScanner::getPSVIHandler() const
1103{
1104    return fPSVIHandler;
1105}
1106
1107inline PSVIHandler* XMLScanner::getPSVIHandler()
1108{
1109    return fPSVIHandler;
1110}
1111
1112inline bool XMLScanner::getExitOnFirstFatal() const
1113{
1114    return fExitOnFirstFatal;
1115}
1116
1117inline bool XMLScanner::getValidationConstraintFatal() const
1118{
1119    return fValidationConstraintFatal;
1120}
1121
1122inline bool XMLScanner::getInException() const
1123{
1124    return fInException;
1125}
1126
1127inline RefHashTableOf<XMLRefInfo>* XMLScanner::getIDRefList()
1128{
1129    return fValidationContext->getIdRefList();
1130}
1131
1132inline const RefHashTableOf<XMLRefInfo>* XMLScanner::getIDRefList() const
1133{
1134    return fValidationContext->getIdRefList();
1135}
1136
1137inline ValidationContext*  XMLScanner::getValidationContext()
1138{
1139    if (!fEntityDeclPoolRetrieved)
1140    {
1141        fValidationContext->setEntityDeclPool(getEntityDeclPool());
1142        fEntityDeclPoolRetrieved = true;
1143    }
1144
1145    return fValidationContext;
1146}
1147
1148inline const Locator* XMLScanner::getLocator() const
1149{
1150    return &fReaderMgr;
1151}
1152
1153inline const ReaderMgr* XMLScanner::getReaderMgr() const
1154{
1155    return &fReaderMgr;
1156}
1157
1158inline unsigned int XMLScanner::getSrcOffset() const
1159{
1160    return fReaderMgr.getSrcOffset();
1161}
1162
1163inline bool XMLScanner::getStandalone() const
1164{
1165    return fStandalone;
1166}
1167
1168inline XMLScanner::ValSchemes XMLScanner::getValidationScheme() const
1169{
1170    return fValScheme;
1171}
1172
1173inline const XMLValidator* XMLScanner::getValidator() const
1174{
1175    return fValidator;
1176}
1177
1178inline XMLValidator* XMLScanner::getValidator()
1179{
1180    return fValidator;
1181}
1182
1183inline bool XMLScanner::getDoSchema() const
1184{
1185    return fDoSchema;
1186}
1187
1188inline bool XMLScanner::getValidationSchemaFullChecking() const
1189{
1190    return fSchemaFullChecking;
1191}
1192
1193inline int XMLScanner::getErrorCount()
1194{
1195    return fErrorCount;
1196}
1197
1198inline bool XMLScanner::isValidatorFromUser()
1199{
1200    return fValidatorFromUser;
1201}
1202
1203inline unsigned int XMLScanner::getEmptyNamespaceId() const
1204{
1205    return fEmptyNamespaceId;
1206}
1207
1208inline unsigned int XMLScanner::getUnknownNamespaceId() const
1209{
1210    return fUnknownNamespaceId;
1211}
1212
1213inline unsigned int XMLScanner::getXMLNamespaceId() const
1214{
1215    return fXMLNamespaceId;
1216}
1217
1218inline unsigned int XMLScanner::getXMLNSNamespaceId() const
1219{
1220    return fXMLNSNamespaceId;
1221}
1222
1223inline const XMLStringPool* XMLScanner::getURIStringPool() const
1224{
1225    return fURIStringPool;
1226}
1227
1228inline XMLStringPool* XMLScanner::getURIStringPool()
1229{
1230    return fURIStringPool;
1231}
1232
1233inline bool XMLScanner::getHasNoDTD() const
1234{
1235    return fHasNoDTD;
1236}
1237
1238inline XMLCh* XMLScanner::getExternalSchemaLocation() const
1239{
1240    return fExternalSchemaLocation;
1241}
1242
1243inline XMLCh* XMLScanner::getExternalNoNamespaceSchemaLocation() const
1244{
1245    return fExternalNoNamespaceSchemaLocation;
1246}
1247
1248inline SecurityManager* XMLScanner::getSecurityManager() const
1249{
1250    return fSecurityManager;
1251}
1252
1253inline bool XMLScanner::getLoadExternalDTD() const
1254{
1255    return fLoadExternalDTD;
1256}
1257
1258inline bool XMLScanner::getNormalizeData() const
1259{
1260    return fNormalizeData;
1261}
1262
1263inline bool XMLScanner::isCachingGrammarFromParse() const
1264{
1265    return fToCacheGrammar;
1266}
1267
1268inline bool XMLScanner::isUsingCachedGrammarInParse() const
1269{
1270    return fUseCachedGrammar;
1271}
1272
1273inline bool XMLScanner::getCalculateSrcOfs() const
1274{
1275    return fCalculateSrcOfs;
1276}
1277
1278inline Grammar* XMLScanner::getRootGrammar() const
1279{
1280    return fRootGrammar;
1281}
1282
1283inline bool XMLScanner::getStandardUriConformant() const
1284{
1285    return fStandardUriConformant;
1286}
1287
1288inline XMLReader::XMLVersion XMLScanner::getXMLVersion() const
1289{
1290        return fXMLVersion;
1291}
1292
1293inline MemoryManager* XMLScanner::getMemoryManager() const
1294{
1295    return fMemoryManager;
1296}
1297
1298inline ValueVectorOf<PrefMapElem*>* XMLScanner::getNamespaceContext() const
1299{
1300    return fElemStack.getNamespaceMap();
1301}
1302
1303inline unsigned int XMLScanner::getPrefixId(const XMLCh* const prefix) const
1304{
1305    return fElemStack.getPrefixId(prefix);
1306}
1307
1308inline const XMLCh* XMLScanner::getPrefixForId(unsigned int prefId) const
1309{
1310    return fElemStack.getPrefixForId(prefId);
1311}
1312
1313// ---------------------------------------------------------------------------
1314//  XMLScanner: Setter methods
1315// ---------------------------------------------------------------------------
1316inline void XMLScanner::setDocHandler(XMLDocumentHandler* const docHandler)
1317{
1318    fDocHandler = docHandler;
1319}
1320
1321inline void XMLScanner::setDocTypeHandler(DocTypeHandler* const docTypeHandler)
1322{
1323    fDocTypeHandler = docTypeHandler;
1324}
1325
1326inline void XMLScanner::setErrorHandler(ErrorHandler* const handler)
1327{
1328    fErrorHandler = handler;
1329}
1330
1331inline void XMLScanner::setPSVIHandler(PSVIHandler* const handler)
1332{
1333    fPSVIHandler = handler;
1334}
1335
1336inline void XMLScanner::setEntityHandler(XMLEntityHandler* const entityHandler)
1337{
1338    fEntityHandler = entityHandler;
1339    fReaderMgr.setEntityHandler(entityHandler);
1340}
1341
1342inline void XMLScanner::setErrorReporter(XMLErrorReporter* const errHandler)
1343{
1344    fErrorReporter = errHandler;
1345}
1346
1347inline void XMLScanner::setExitOnFirstFatal(const bool newValue)
1348{
1349    fExitOnFirstFatal = newValue;
1350}
1351
1352
1353inline void XMLScanner::setValidationConstraintFatal(const bool newValue)
1354{
1355    fValidationConstraintFatal = newValue;
1356}
1357
1358inline void XMLScanner::setValidationScheme(const ValSchemes newScheme)
1359{
1360    fValScheme = newScheme;
1361
1362    // validation flag for Val_Auto is set to false by default,
1363    //   and will be turned to true if a grammar is seen
1364    if (fValScheme == Val_Always)
1365        fValidate = true;
1366    else
1367        fValidate = false;
1368}
1369
1370inline void XMLScanner::setDoSchema(const bool doSchema)
1371{
1372    fDoSchema = doSchema;
1373}
1374
1375inline void XMLScanner::setDoNamespaces(const bool doNamespaces)
1376{
1377    fDoNamespaces = doNamespaces;
1378}
1379
1380inline void XMLScanner::setValidationSchemaFullChecking(const bool schemaFullChecking)
1381{
1382    fSchemaFullChecking = schemaFullChecking;
1383}
1384
1385inline void XMLScanner::setHasNoDTD(const bool hasNoDTD)
1386{
1387    fHasNoDTD = hasNoDTD;
1388}
1389
1390inline void XMLScanner::setRootElemName(XMLCh* rootElemName)
1391{
1392    fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName;
1393    fRootElemName = XMLString::replicate(rootElemName, fMemoryManager);
1394}
1395
1396inline void XMLScanner::setExternalSchemaLocation(const XMLCh* const schemaLocation)
1397{
1398    fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation;
1399    fExternalSchemaLocation = XMLString::replicate(schemaLocation, fMemoryManager);
1400}
1401
1402inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation)
1403{
1404    fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation;
1405    fExternalNoNamespaceSchemaLocation = XMLString::replicate(noNamespaceSchemaLocation, fMemoryManager);
1406}
1407
1408inline void XMLScanner::setExternalSchemaLocation(const char* const schemaLocation)
1409{
1410    fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation;
1411    fExternalSchemaLocation = XMLString::transcode(schemaLocation, fMemoryManager);
1412}
1413
1414inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation)
1415{
1416    fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation;
1417    fExternalNoNamespaceSchemaLocation = XMLString::transcode(noNamespaceSchemaLocation, fMemoryManager);
1418}
1419
1420inline void XMLScanner::setSecurityManager(SecurityManager* const securityManager)
1421{
1422    fSecurityManager = securityManager;
1423    if(securityManager != 0)
1424    {
1425        fEntityExpansionLimit = securityManager->getEntityExpansionLimit();
1426        fEntityExpansionCount = 0;
1427    }
1428}
1429
1430inline void XMLScanner::setLoadExternalDTD(const bool loadDTD)
1431{
1432    fLoadExternalDTD = loadDTD;
1433}
1434
1435inline void XMLScanner::setNormalizeData(const bool normalizeData)
1436{
1437    fNormalizeData = normalizeData;
1438}
1439
1440inline void XMLScanner::cacheGrammarFromParse(const bool newValue)
1441{
1442    fToCacheGrammar = newValue;
1443}
1444
1445inline void XMLScanner::useCachedGrammarInParse(const bool newValue)
1446{
1447    fUseCachedGrammar = newValue;
1448}
1449
1450inline void XMLScanner::setCalculateSrcOfs(const bool newValue)
1451{
1452    fCalculateSrcOfs = newValue;
1453}
1454
1455inline void XMLScanner::setStandardUriConformant(const bool newValue)
1456{
1457    fStandardUriConformant = newValue;
1458    fReaderMgr.setStandardUriConformant(newValue);
1459}
1460
1461// ---------------------------------------------------------------------------
1462//  XMLScanner: Mutator methods
1463// ---------------------------------------------------------------------------
1464inline void XMLScanner::incrementErrorCount()
1465{
1466    ++fErrorCount;
1467}
1468
1469// ---------------------------------------------------------------------------
1470//  XMLScanner: Deprecated methods
1471// ---------------------------------------------------------------------------
1472inline bool XMLScanner::getDoValidation() const
1473{
1474    return fValidate;
1475}
1476
1477inline void XMLScanner::setDoValidation(const bool validate)
1478{
1479    fValidate = validate;
1480    if (fValidate)
1481        fValScheme = Val_Always;
1482    else
1483        fValScheme = Val_Never;
1484}
1485
1486inline void XMLScanner::resetValidationContext()
1487{
1488    fValidationContext->clearIdRefList();
1489    fValidationContext->setEntityDeclPool(0);
1490    fEntityDeclPoolRetrieved = false;
1491}
1492
1493XERCES_CPP_NAMESPACE_END
1494
1495#endif
1496
Note: See TracBrowser for help on using the repository browser.