1 | /* |
---|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
3 | * contributor license agreements. See the NOTICE file distributed with |
---|
4 | * this work for additional information regarding copyright ownership. |
---|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
6 | * (the "License"); you may not use this file except in compliance with |
---|
7 | * the License. You may obtain a copy of the License at |
---|
8 | * |
---|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
10 | * |
---|
11 | * Unless required by applicable law or agreed to in writing, software |
---|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
14 | * See the License for the specific language governing permissions and |
---|
15 | * limitations under the License. |
---|
16 | */ |
---|
17 | |
---|
18 | /* |
---|
19 | * $Id: XMLScanner.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
20 | */ |
---|
21 | |
---|
22 | #if !defined(XMLSCANNER_HPP) |
---|
23 | #define XMLSCANNER_HPP |
---|
24 | |
---|
25 | #include <xercesc/framework/XMLBufferMgr.hpp> |
---|
26 | #include <xercesc/framework/XMLErrorCodes.hpp> |
---|
27 | #include <xercesc/framework/XMLRefInfo.hpp> |
---|
28 | #include <xercesc/util/PlatformUtils.hpp> |
---|
29 | #include <xercesc/util/NameIdPool.hpp> |
---|
30 | #include <xercesc/util/RefHashTableOf.hpp> |
---|
31 | #include <xercesc/util/SecurityManager.hpp> |
---|
32 | #include <xercesc/internal/ReaderMgr.hpp> |
---|
33 | #include <xercesc/internal/ElemStack.hpp> |
---|
34 | #include <xercesc/validators/DTD/DTDEntityDecl.hpp> |
---|
35 | #include <xercesc/framework/XMLAttr.hpp> |
---|
36 | #include <xercesc/framework/ValidationContext.hpp> |
---|
37 | #include <xercesc/validators/common/GrammarResolver.hpp> |
---|
38 | |
---|
39 | XERCES_CPP_NAMESPACE_BEGIN |
---|
40 | |
---|
41 | class InputSource; |
---|
42 | class XMLDocumentHandler; |
---|
43 | class XMLEntityHandler; |
---|
44 | class ErrorHandler; |
---|
45 | class DocTypeHandler; |
---|
46 | class XMLPScanToken; |
---|
47 | class XMLStringPool; |
---|
48 | class Grammar; |
---|
49 | class XMLValidator; |
---|
50 | class MemoryManager; |
---|
51 | class PSVIHandler; |
---|
52 | |
---|
53 | |
---|
54 | struct PSVIElemContext |
---|
55 | { |
---|
56 | bool fIsSpecified; |
---|
57 | bool fErrorOccurred; |
---|
58 | int fElemDepth; |
---|
59 | int fFullValidationDepth; |
---|
60 | int fNoneValidationDepth; |
---|
61 | DatatypeValidator* fCurrentDV; |
---|
62 | ComplexTypeInfo* fCurrentTypeInfo; |
---|
63 | const XMLCh* fNormalizedValue; |
---|
64 | }; |
---|
65 | |
---|
66 | // This is the mondo scanner class, which does the vast majority of the |
---|
67 | // work of parsing. It handles reading in input and spitting out events |
---|
68 | // to installed handlers. |
---|
69 | class XMLPARSER_EXPORT XMLScanner : public XMemory, public XMLBufferFullHandler |
---|
70 | { |
---|
71 | public : |
---|
72 | // ----------------------------------------------------------------------- |
---|
73 | // Public class types |
---|
74 | // |
---|
75 | // NOTE: These should really be private, but some of the compilers we |
---|
76 | // have to deal with are too stupid to understand this. |
---|
77 | // |
---|
78 | // DeclTypes |
---|
79 | // Used by scanXMLDecl() to know what type of decl it should scan. |
---|
80 | // Text decls have slightly different rules from XMLDecls. |
---|
81 | // |
---|
82 | // EntityExpRes |
---|
83 | // These are the values returned from the entity expansion method, |
---|
84 | // to indicate how it went. |
---|
85 | // |
---|
86 | // XMLTokens |
---|
87 | // These represent the possible types of input we can get while |
---|
88 | // scanning content. |
---|
89 | // |
---|
90 | // ValScheme |
---|
91 | // This indicates what the scanner should do in terms of validation. |
---|
92 | // 'Auto' means if there is any int/ext subset, then validate. Else, |
---|
93 | // don't. |
---|
94 | // ----------------------------------------------------------------------- |
---|
95 | enum DeclTypes |
---|
96 | { |
---|
97 | Decl_Text |
---|
98 | , Decl_XML |
---|
99 | }; |
---|
100 | |
---|
101 | enum EntityExpRes |
---|
102 | { |
---|
103 | EntityExp_Pushed |
---|
104 | , EntityExp_Returned |
---|
105 | , EntityExp_Failed |
---|
106 | }; |
---|
107 | |
---|
108 | enum XMLTokens |
---|
109 | { |
---|
110 | Token_CData |
---|
111 | , Token_CharData |
---|
112 | , Token_Comment |
---|
113 | , Token_EndTag |
---|
114 | , Token_EOF |
---|
115 | , Token_PI |
---|
116 | , Token_StartTag |
---|
117 | , Token_Unknown |
---|
118 | }; |
---|
119 | |
---|
120 | enum ValSchemes |
---|
121 | { |
---|
122 | Val_Never |
---|
123 | , Val_Always |
---|
124 | , Val_Auto |
---|
125 | }; |
---|
126 | |
---|
127 | |
---|
128 | // ----------------------------------------------------------------------- |
---|
129 | // Constructors and Destructor |
---|
130 | // ----------------------------------------------------------------------- |
---|
131 | XMLScanner |
---|
132 | ( |
---|
133 | XMLValidator* const valToAdopt |
---|
134 | , GrammarResolver* const grammarResolver |
---|
135 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
136 | ); |
---|
137 | XMLScanner |
---|
138 | ( |
---|
139 | XMLDocumentHandler* const docHandler |
---|
140 | , DocTypeHandler* const docTypeHandler |
---|
141 | , XMLEntityHandler* const entityHandler |
---|
142 | , XMLErrorReporter* const errReporter |
---|
143 | , XMLValidator* const valToAdopt |
---|
144 | , GrammarResolver* const grammarResolver |
---|
145 | , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager |
---|
146 | ); |
---|
147 | virtual ~XMLScanner(); |
---|
148 | |
---|
149 | |
---|
150 | // ----------------------------------------------------------------------- |
---|
151 | // Error emitter methods |
---|
152 | // ----------------------------------------------------------------------- |
---|
153 | bool emitErrorWillThrowException(const XMLErrs::Codes toEmit); |
---|
154 | void emitError(const XMLErrs::Codes toEmit); |
---|
155 | void emitError |
---|
156 | ( |
---|
157 | const XMLErrs::Codes toEmit |
---|
158 | , const XMLCh* const text1 |
---|
159 | , const XMLCh* const text2 = 0 |
---|
160 | , const XMLCh* const text3 = 0 |
---|
161 | , const XMLCh* const text4 = 0 |
---|
162 | ); |
---|
163 | void emitError |
---|
164 | ( |
---|
165 | const XMLErrs::Codes toEmit |
---|
166 | , const char* const text1 |
---|
167 | , const char* const text2 = 0 |
---|
168 | , const char* const text3 = 0 |
---|
169 | , const char* const text4 = 0 |
---|
170 | ); |
---|
171 | void emitError |
---|
172 | ( |
---|
173 | const XMLErrs::Codes toEmit |
---|
174 | , const XMLExcepts::Codes originalErrorCode |
---|
175 | , const XMLCh* const text1 = 0 |
---|
176 | , const XMLCh* const text2 = 0 |
---|
177 | , const XMLCh* const text3 = 0 |
---|
178 | , const XMLCh* const text4 = 0 |
---|
179 | ); |
---|
180 | |
---|
181 | // ----------------------------------------------------------------------- |
---|
182 | // Implementation of XMLBufferFullHandler interface |
---|
183 | // ----------------------------------------------------------------------- |
---|
184 | |
---|
185 | virtual bool bufferFull(XMLBuffer& toSend) |
---|
186 | { |
---|
187 | sendCharData(toSend); |
---|
188 | return true; |
---|
189 | } |
---|
190 | |
---|
191 | virtual Grammar::GrammarType getCurrentGrammarType() const; |
---|
192 | |
---|
193 | // ----------------------------------------------------------------------- |
---|
194 | // Public pure virtual methods |
---|
195 | // ----------------------------------------------------------------------- |
---|
196 | virtual const XMLCh* getName() const = 0; |
---|
197 | virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool() = 0; |
---|
198 | virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const = 0; |
---|
199 | virtual unsigned int resolveQName |
---|
200 | ( |
---|
201 | const XMLCh* const qName |
---|
202 | , XMLBuffer& prefixBufToFill |
---|
203 | , const short mode |
---|
204 | , int& prefixColonPos |
---|
205 | ) = 0; |
---|
206 | virtual void scanDocument |
---|
207 | ( |
---|
208 | const InputSource& src |
---|
209 | ) = 0; |
---|
210 | virtual bool scanNext(XMLPScanToken& toFill) = 0; |
---|
211 | virtual Grammar* loadGrammar |
---|
212 | ( |
---|
213 | const InputSource& src |
---|
214 | , const short grammarType |
---|
215 | , const bool toCache = false |
---|
216 | ) = 0; |
---|
217 | |
---|
218 | // ----------------------------------------------------------------------- |
---|
219 | // Getter methods |
---|
220 | // ----------------------------------------------------------------------- |
---|
221 | const XMLDocumentHandler* getDocHandler() const; |
---|
222 | XMLDocumentHandler* getDocHandler(); |
---|
223 | const DocTypeHandler* getDocTypeHandler() const; |
---|
224 | DocTypeHandler* getDocTypeHandler(); |
---|
225 | bool getDoNamespaces() const; |
---|
226 | ValSchemes getValidationScheme() const; |
---|
227 | bool getDoSchema() const; |
---|
228 | bool getValidationSchemaFullChecking() const; |
---|
229 | bool getIdentityConstraintChecking() const; |
---|
230 | const XMLEntityHandler* getEntityHandler() const; |
---|
231 | XMLEntityHandler* getEntityHandler(); |
---|
232 | const XMLErrorReporter* getErrorReporter() const; |
---|
233 | XMLErrorReporter* getErrorReporter(); |
---|
234 | const ErrorHandler* getErrorHandler() const; |
---|
235 | ErrorHandler* getErrorHandler(); |
---|
236 | const PSVIHandler* getPSVIHandler() const; |
---|
237 | PSVIHandler* getPSVIHandler(); |
---|
238 | bool getExitOnFirstFatal() const; |
---|
239 | bool getValidationConstraintFatal() const; |
---|
240 | RefHashTableOf<XMLRefInfo>* getIDRefList(); |
---|
241 | const RefHashTableOf<XMLRefInfo>* getIDRefList() const; |
---|
242 | |
---|
243 | ValidationContext* getValidationContext(); |
---|
244 | |
---|
245 | bool getInException() const; |
---|
246 | /*bool getLastExtLocation |
---|
247 | ( |
---|
248 | XMLCh* const sysIdToFill |
---|
249 | , const unsigned int maxSysIdChars |
---|
250 | , XMLCh* const pubIdToFill |
---|
251 | , const unsigned int maxPubIdChars |
---|
252 | , XMLSSize_t& lineToFill |
---|
253 | , XMLSSize_t& colToFill |
---|
254 | ) const;*/ |
---|
255 | const Locator* getLocator() const; |
---|
256 | const ReaderMgr* getReaderMgr() const; |
---|
257 | unsigned int getSrcOffset() const; |
---|
258 | bool getStandalone() const; |
---|
259 | const XMLValidator* getValidator() const; |
---|
260 | XMLValidator* getValidator(); |
---|
261 | int getErrorCount(); |
---|
262 | const XMLStringPool* getURIStringPool() const; |
---|
263 | XMLStringPool* getURIStringPool(); |
---|
264 | bool getHasNoDTD() const; |
---|
265 | XMLCh* getExternalSchemaLocation() const; |
---|
266 | XMLCh* getExternalNoNamespaceSchemaLocation() const; |
---|
267 | SecurityManager* getSecurityManager() const; |
---|
268 | bool getLoadExternalDTD() const; |
---|
269 | bool getNormalizeData() const; |
---|
270 | bool isCachingGrammarFromParse() const; |
---|
271 | bool isUsingCachedGrammarInParse() const; |
---|
272 | bool getCalculateSrcOfs() const; |
---|
273 | Grammar* getRootGrammar() const; |
---|
274 | XMLReader::XMLVersion getXMLVersion() const; |
---|
275 | MemoryManager* getMemoryManager() const; |
---|
276 | ValueVectorOf<PrefMapElem*>* getNamespaceContext() const; |
---|
277 | unsigned int getPrefixId(const XMLCh* const prefix) const; |
---|
278 | const XMLCh* getPrefixForId(unsigned int prefId) const; |
---|
279 | |
---|
280 | bool getGenerateSyntheticAnnotations() const; |
---|
281 | bool getValidateAnnotations() const; |
---|
282 | bool getIgnoreCachedDTD() const; |
---|
283 | bool getIgnoreAnnotations() const; |
---|
284 | bool getDisableDefaultEntityResolution() const; |
---|
285 | bool getSkipDTDValidation() const; |
---|
286 | |
---|
287 | // ----------------------------------------------------------------------- |
---|
288 | // Getter methods |
---|
289 | // ----------------------------------------------------------------------- |
---|
290 | /** |
---|
291 | * When an attribute name has no prefix, unlike elements, it is not mapped |
---|
292 | * to the global namespace. So, in order to have something to map it to |
---|
293 | * for practical purposes, a id for an empty URL is created and used for |
---|
294 | * such names. |
---|
295 | * |
---|
296 | * @return The URL pool id of the URL for an empty URL "". |
---|
297 | */ |
---|
298 | unsigned int getEmptyNamespaceId() const; |
---|
299 | |
---|
300 | /** |
---|
301 | * When a prefix is found that has not been mapped, an error is issued. |
---|
302 | * However, if the parser has been instructed not to stop on the first |
---|
303 | * fatal error, it needs to be able to continue. To do so, it will map |
---|
304 | * that prefix tot his magic unknown namespace id. |
---|
305 | * |
---|
306 | * @return The URL pool id of the URL for the unknown prefix |
---|
307 | * namespace. |
---|
308 | */ |
---|
309 | unsigned int getUnknownNamespaceId() const; |
---|
310 | |
---|
311 | /** |
---|
312 | * The prefix 'xml' is a magic prefix, defined by the XML spec and |
---|
313 | * requiring no prior definition. This method returns the id for the |
---|
314 | * intrinsically defined URL for this prefix. |
---|
315 | * |
---|
316 | * @return The URL pool id of the URL for the 'xml' prefix. |
---|
317 | */ |
---|
318 | unsigned int getXMLNamespaceId() const; |
---|
319 | |
---|
320 | /** |
---|
321 | * The prefix 'xmlns' is a magic prefix, defined by the namespace spec |
---|
322 | * and requiring no prior definition. This method returns the id for the |
---|
323 | * intrinsically defined URL for this prefix. |
---|
324 | * |
---|
325 | * @return The URL pool id of the URL for the 'xmlns' prefix. |
---|
326 | */ |
---|
327 | unsigned int getXMLNSNamespaceId() const; |
---|
328 | |
---|
329 | /** |
---|
330 | * This method find the passed URI id in its URI pool and |
---|
331 | * copy the text of that URI into the passed buffer. |
---|
332 | */ |
---|
333 | bool getURIText |
---|
334 | ( |
---|
335 | const unsigned int uriId |
---|
336 | , XMLBuffer& uriBufToFill |
---|
337 | ) const; |
---|
338 | |
---|
339 | const XMLCh* getURIText(const unsigned int uriId) const; |
---|
340 | |
---|
341 | /* tell if the validator comes from user */ |
---|
342 | bool isValidatorFromUser(); |
---|
343 | |
---|
344 | /* tell if standard URI are forced */ |
---|
345 | bool getStandardUriConformant() const; |
---|
346 | |
---|
347 | // ----------------------------------------------------------------------- |
---|
348 | // Setter methods |
---|
349 | // ----------------------------------------------------------------------- |
---|
350 | void setDocHandler(XMLDocumentHandler* const docHandler); |
---|
351 | void setDocTypeHandler(DocTypeHandler* const docTypeHandler); |
---|
352 | void setDoNamespaces(const bool doNamespaces); |
---|
353 | void setEntityHandler(XMLEntityHandler* const docTypeHandler); |
---|
354 | void setErrorReporter(XMLErrorReporter* const errHandler); |
---|
355 | void setErrorHandler(ErrorHandler* const handler); |
---|
356 | void setPSVIHandler(PSVIHandler* const handler); |
---|
357 | void setURIStringPool(XMLStringPool* const stringPool); |
---|
358 | void setExitOnFirstFatal(const bool newValue); |
---|
359 | void setValidationConstraintFatal(const bool newValue); |
---|
360 | void setValidationScheme(const ValSchemes newScheme); |
---|
361 | void setValidator(XMLValidator* const valToAdopt); |
---|
362 | void setDoSchema(const bool doSchema); |
---|
363 | void setValidationSchemaFullChecking(const bool schemaFullChecking); |
---|
364 | void setIdentityConstraintChecking(const bool identityConstraintChecking); |
---|
365 | void setHasNoDTD(const bool hasNoDTD); |
---|
366 | void cacheGrammarFromParse(const bool newValue); |
---|
367 | void useCachedGrammarInParse(const bool newValue); |
---|
368 | void setRootElemName(XMLCh* rootElemName); |
---|
369 | void setExternalSchemaLocation(const XMLCh* const schemaLocation); |
---|
370 | void setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation); |
---|
371 | void setExternalSchemaLocation(const char* const schemaLocation); |
---|
372 | void setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation); |
---|
373 | void setSecurityManager(SecurityManager* const securityManager); |
---|
374 | void setLoadExternalDTD(const bool loadDTD); |
---|
375 | void setNormalizeData(const bool normalizeData); |
---|
376 | void setCalculateSrcOfs(const bool newValue); |
---|
377 | void setParseSettings(XMLScanner* const refScanner); |
---|
378 | void setStandardUriConformant(const bool newValue); |
---|
379 | void setInputBufferSize(const size_t bufferSize); |
---|
380 | |
---|
381 | void setGenerateSyntheticAnnotations(const bool newValue); |
---|
382 | void setValidateAnnotations(const bool newValue); |
---|
383 | void setIgnoredCachedDTD(const bool newValue); |
---|
384 | void setIgnoreAnnotations(const bool newValue); |
---|
385 | void setDisableDefaultEntityResolution(const bool newValue); |
---|
386 | void setSkipDTDValidation(const bool newValue); |
---|
387 | |
---|
388 | // ----------------------------------------------------------------------- |
---|
389 | // Mutator methods |
---|
390 | // ----------------------------------------------------------------------- |
---|
391 | void incrementErrorCount(void); // For use by XMLValidator |
---|
392 | |
---|
393 | // ----------------------------------------------------------------------- |
---|
394 | // Deprecated methods as of 3.2.0. Use getValidationScheme() and |
---|
395 | // setValidationScheme() instead. |
---|
396 | // ----------------------------------------------------------------------- |
---|
397 | bool getDoValidation() const; |
---|
398 | void setDoValidation(const bool validate); |
---|
399 | |
---|
400 | // ----------------------------------------------------------------------- |
---|
401 | // Document scanning methods |
---|
402 | // |
---|
403 | // scanDocument() does the entire source document. scanFirst(), |
---|
404 | // scanNext(), and scanReset() support a progressive parse. |
---|
405 | // ----------------------------------------------------------------------- |
---|
406 | void scanDocument |
---|
407 | ( |
---|
408 | const XMLCh* const systemId |
---|
409 | ); |
---|
410 | void scanDocument |
---|
411 | ( |
---|
412 | const char* const systemId |
---|
413 | ); |
---|
414 | |
---|
415 | bool scanFirst |
---|
416 | ( |
---|
417 | const InputSource& src |
---|
418 | , XMLPScanToken& toFill |
---|
419 | ); |
---|
420 | bool scanFirst |
---|
421 | ( |
---|
422 | const XMLCh* const systemId |
---|
423 | , XMLPScanToken& toFill |
---|
424 | ); |
---|
425 | bool scanFirst |
---|
426 | ( |
---|
427 | const char* const systemId |
---|
428 | , XMLPScanToken& toFill |
---|
429 | ); |
---|
430 | |
---|
431 | void scanReset(XMLPScanToken& toFill); |
---|
432 | |
---|
433 | bool checkXMLDecl(bool startWithAngle); |
---|
434 | |
---|
435 | // ----------------------------------------------------------------------- |
---|
436 | // Grammar preparsing methods |
---|
437 | // ----------------------------------------------------------------------- |
---|
438 | Grammar* loadGrammar |
---|
439 | ( |
---|
440 | const XMLCh* const systemId |
---|
441 | , const short grammarType |
---|
442 | , const bool toCache = false |
---|
443 | ); |
---|
444 | Grammar* loadGrammar |
---|
445 | ( |
---|
446 | const char* const systemId |
---|
447 | , const short grammarType |
---|
448 | , const bool toCache = false |
---|
449 | ); |
---|
450 | |
---|
451 | // ----------------------------------------------------------------------- |
---|
452 | // Notification that lazy data has been deleted |
---|
453 | // ----------------------------------------------------------------------- |
---|
454 | static void reinitScannerMutex(); |
---|
455 | static void reinitMsgLoader(); |
---|
456 | |
---|
457 | protected: |
---|
458 | // ----------------------------------------------------------------------- |
---|
459 | // Protected pure virtual methods |
---|
460 | // ----------------------------------------------------------------------- |
---|
461 | virtual void scanCDSection() = 0; |
---|
462 | virtual void scanCharData(XMLBuffer& toToUse) = 0; |
---|
463 | virtual EntityExpRes scanEntityRef |
---|
464 | ( |
---|
465 | const bool inAttVal |
---|
466 | , XMLCh& firstCh |
---|
467 | , XMLCh& secondCh |
---|
468 | , bool& escaped |
---|
469 | ) = 0; |
---|
470 | virtual void scanDocTypeDecl() = 0; |
---|
471 | virtual void scanReset(const InputSource& src) = 0; |
---|
472 | virtual void sendCharData(XMLBuffer& toSend) = 0; |
---|
473 | |
---|
474 | //return owned by the caller |
---|
475 | virtual InputSource* resolveSystemId(const XMLCh* const /*sysId*/ |
---|
476 | ,const XMLCh* const /*pubId*/) {return 0;}; |
---|
477 | |
---|
478 | // ----------------------------------------------------------------------- |
---|
479 | // Protected scanning methods |
---|
480 | // ----------------------------------------------------------------------- |
---|
481 | bool scanCharRef(XMLCh& toFill, XMLCh& second); |
---|
482 | void scanComment(); |
---|
483 | bool scanEq(bool inDecl = false); |
---|
484 | void scanMiscellaneous(); |
---|
485 | void scanPI(); |
---|
486 | void scanProlog(); |
---|
487 | void scanXMLDecl(const DeclTypes type); |
---|
488 | |
---|
489 | // ----------------------------------------------------------------------- |
---|
490 | // Private helper methods |
---|
491 | // ----------------------------------------------------------------------- |
---|
492 | void checkInternalDTD(bool hasExtSubset, const XMLCh* const sysId, const XMLCh* const pubId); |
---|
493 | void checkIDRefs(); |
---|
494 | bool isLegalToken(const XMLPScanToken& toCheck); |
---|
495 | XMLTokens senseNextToken(unsigned int& orgReader); |
---|
496 | void initValidator(XMLValidator* theValidator); |
---|
497 | inline void resetValidationContext(); |
---|
498 | unsigned int *getNewUIntPtr(); |
---|
499 | void resetUIntPool(); |
---|
500 | void recreateUIntPool(); |
---|
501 | |
---|
502 | inline |
---|
503 | void setAttrDupChkRegistry |
---|
504 | ( |
---|
505 | const unsigned int &attrNumber |
---|
506 | , bool &toUseHashTable |
---|
507 | ); |
---|
508 | |
---|
509 | // ----------------------------------------------------------------------- |
---|
510 | // Data members |
---|
511 | // |
---|
512 | // fBufferSize |
---|
513 | // Maximum input buffer size |
---|
514 | // |
---|
515 | // fAttrList |
---|
516 | // Every time we get a new element start tag, we have to pass to |
---|
517 | // the document handler the attributes found. To make it more |
---|
518 | // efficient we keep this ref vector of XMLAttr objects around. We |
---|
519 | // just reuse it over and over, allowing it to grow to meet the |
---|
520 | // peak need. |
---|
521 | // |
---|
522 | // fBufMgr |
---|
523 | // This is a manager for temporary buffers used during scanning. |
---|
524 | // For efficiency we must use a set of static buffers, but we have |
---|
525 | // to insure that they are not incorrectly reused. So this manager |
---|
526 | // provides the smarts to hand out buffers as required. |
---|
527 | // |
---|
528 | // fDocHandler |
---|
529 | // The client code's document handler. If zero, then no document |
---|
530 | // handler callouts are done. We don't adopt it. |
---|
531 | // |
---|
532 | // fDocTypeHandler |
---|
533 | // The client code's document type handler (used by DTD Validator). |
---|
534 | // |
---|
535 | // fDoNamespaces |
---|
536 | // This flag indicates whether the client code wants us to do |
---|
537 | // namespaces or not. If the installed validator indicates that it |
---|
538 | // has to do namespaces, then this is ignored. |
---|
539 | // |
---|
540 | // fEntityHandler |
---|
541 | // The client code's entity handler. If zero, then no entity handler |
---|
542 | // callouts are done. We don't adopt it. |
---|
543 | // |
---|
544 | // fErrorReporter |
---|
545 | // The client code's error reporter. If zero, then no error reporter |
---|
546 | // callouts are done. We don't adopt it. |
---|
547 | // |
---|
548 | // fErrorHandler |
---|
549 | // The client code's error handler. Need to store this info for |
---|
550 | // Schema parse error handling. |
---|
551 | // |
---|
552 | // fPSVIHandler |
---|
553 | // The client code's PSVI handler. |
---|
554 | // |
---|
555 | // fExitOnFirstFatal |
---|
556 | // This indicates whether we bail out on the first fatal XML error |
---|
557 | // or not. It defaults to true, which is the strict XML way, but it |
---|
558 | // can be changed. |
---|
559 | // |
---|
560 | // fValidationConstraintFatal |
---|
561 | // This indicates whether we treat validation constraint errors as |
---|
562 | // fatal errors or not. It defaults to false, but it can be changed. |
---|
563 | // |
---|
564 | // fIDRefList |
---|
565 | // This is a list of XMLRefInfo objects. This member lets us do all |
---|
566 | // needed ID-IDREF balancing checks. |
---|
567 | // |
---|
568 | // fInException |
---|
569 | // To avoid a circular freakout when we catch an exception and emit |
---|
570 | // it, which would normally throw again if the 'fail on first error' |
---|
571 | // flag is one. |
---|
572 | // |
---|
573 | // fReaderMgr |
---|
574 | // This is the reader manager, from which we get characters. It |
---|
575 | // manages the reader stack for us, and provides a lot of convenience |
---|
576 | // methods to do specialized checking for chars, sequences of chars, |
---|
577 | // skipping chars, etc... |
---|
578 | // |
---|
579 | // fScannerId |
---|
580 | // fSequenceId |
---|
581 | // These are used for progressive parsing, to make sure that the |
---|
582 | // client code does the right thing at the right time. |
---|
583 | // |
---|
584 | // fStandalone |
---|
585 | // Indicates whether the document is standalone or not. Defaults to |
---|
586 | // no, but can be overridden in the XMLDecl. |
---|
587 | // |
---|
588 | // fHasNoDTD |
---|
589 | // Indicates the document has no DTD or has only an internal DTD subset |
---|
590 | // which contains no parameter entity references. |
---|
591 | // |
---|
592 | // fValidate |
---|
593 | // Indicates whether any validation should be done. This is defined |
---|
594 | // by the existence of a Grammar together with fValScheme. |
---|
595 | // |
---|
596 | // fValidator |
---|
597 | // The installed validator. We look at them via the abstract |
---|
598 | // validator interface, and don't know what it actual is. |
---|
599 | // Either point to user's installed validator, or fDTDValidator |
---|
600 | // or fSchemaValidator. |
---|
601 | // |
---|
602 | // fValidatorFromUser |
---|
603 | // This flag indicates whether the validator was installed from |
---|
604 | // user. If false, then the validator was created by the Scanner. |
---|
605 | // |
---|
606 | // fValScheme |
---|
607 | // This is the currently set validation scheme. It defaults to |
---|
608 | // 'never', but can be set by the client. |
---|
609 | // |
---|
610 | // fErrorCount |
---|
611 | // The number of errors we've encountered. |
---|
612 | // |
---|
613 | // fDoSchema |
---|
614 | // This flag indicates whether the client code wants Schema to |
---|
615 | // be processed or not. |
---|
616 | // |
---|
617 | // fSchemaFullChecking |
---|
618 | // This flag indicates whether the client code wants full Schema |
---|
619 | // constraint checking. |
---|
620 | // |
---|
621 | // fIdentityConstraintChecking |
---|
622 | // This flag indicates whether the client code wants Identity |
---|
623 | // Constraint checking, defaulted to true to maintain backward |
---|
624 | // compatibility (to minimize supprise) |
---|
625 | // |
---|
626 | // fAttName |
---|
627 | // fAttValue |
---|
628 | // fCDataBuf |
---|
629 | // fNameBuf |
---|
630 | // fQNameBuf |
---|
631 | // fPrefixBuf |
---|
632 | // For the most part, buffers are obtained from the fBufMgr object |
---|
633 | // on the fly. However, for the start tag scan, we have a set of |
---|
634 | // fixed buffers for performance reasons. These are used a lot and |
---|
635 | // there are a number of them, so asking the buffer manager each |
---|
636 | // time for new buffers is a bit too much overhead. |
---|
637 | // |
---|
638 | // fEmptyNamespaceId |
---|
639 | // This is the id of the empty namespace URI. This is a special one |
---|
640 | // because of the xmlns="" type of deal. We have to quickly sense |
---|
641 | // that its the empty namespace. |
---|
642 | // |
---|
643 | // fUnknownNamespaceId |
---|
644 | // This is the id of the namespace URI which is assigned to the |
---|
645 | // global namespace. Its for debug purposes only, since there is no |
---|
646 | // real global namespace URI. Its set by the derived class. |
---|
647 | // |
---|
648 | // fXMLNamespaceId |
---|
649 | // fXMLNSNamespaceId |
---|
650 | // These are the ids of the namespace URIs which are assigned to the |
---|
651 | // 'xml' and 'xmlns' special prefixes. The former is officially |
---|
652 | // defined but the latter is not, so we just provide one for debug |
---|
653 | // purposes. |
---|
654 | // |
---|
655 | // fSchemaNamespaceId |
---|
656 | // This is the id of the schema namespace URI. |
---|
657 | // |
---|
658 | // fGrammarResolver |
---|
659 | // Grammar Pool that stores all the grammars. Key is namespace for |
---|
660 | // schema and system id for external DTD. When caching a grammar, if |
---|
661 | // a grammar is already in the pool, it will be replaced with the |
---|
662 | // new parsed one. |
---|
663 | // |
---|
664 | // fGrammar |
---|
665 | // Current Grammar used by the Scanner and Validator |
---|
666 | // |
---|
667 | // fRootGrammar |
---|
668 | // The grammar where the root element is declared. |
---|
669 | // |
---|
670 | // fGrammarType |
---|
671 | // Current Grammar Type. Store this value instead of calling getGrammarType |
---|
672 | // all the time for faster performance. |
---|
673 | // |
---|
674 | // fURIStringPool |
---|
675 | // This is a pool for URIs with unique ids assigned. We use a standard |
---|
676 | // string pool class. This pool is going to be shared by all Grammar. |
---|
677 | // Use only if namespace is turned on. |
---|
678 | // |
---|
679 | // fRootElemName |
---|
680 | // No matter we are using DTD or Schema Grammar, if a DOCTYPE exists, |
---|
681 | // we need to verify the root element name. So store the rootElement |
---|
682 | // that is used in the DOCTYPE in the Scanner instead of in the DTDGrammar |
---|
683 | // where it used to |
---|
684 | // |
---|
685 | // fExternalSchemaLocation |
---|
686 | // The list of Namespace/SchemaLocation that was specified externally |
---|
687 | // using setExternalSchemaLocation. |
---|
688 | // |
---|
689 | // fExternalNoNamespaceSchemaLocation |
---|
690 | // The no target namespace XML Schema Location that was specified |
---|
691 | // externally using setExternalNoNamespaceSchemaLocation. |
---|
692 | // |
---|
693 | // fSecurityManager |
---|
694 | // The SecurityManager instance; as and when set by the application. |
---|
695 | // |
---|
696 | // fEntityExpansionLimit |
---|
697 | // The number of entity expansions to be permitted while processing this document |
---|
698 | // Only meaningful when fSecurityManager != 0 |
---|
699 | // |
---|
700 | // fEntityExpansionCount |
---|
701 | // The number of general entities expanded so far in this document. |
---|
702 | // Only meaningful when fSecurityManager != null |
---|
703 | // |
---|
704 | // fLoadExternalDTD |
---|
705 | // This flag indicates whether the external DTD be loaded or not |
---|
706 | // |
---|
707 | // fNormalizeData |
---|
708 | // This flag indicates whether the parser should perform datatype |
---|
709 | // normalization that is defined in the schema. |
---|
710 | // |
---|
711 | // fCalculateSrcOfs |
---|
712 | // This flag indicates the parser should calculate the source offset. |
---|
713 | // Turning this on may impact performance. |
---|
714 | // |
---|
715 | // fStandardUriConformant |
---|
716 | // This flag controls whether we force conformant URI |
---|
717 | // |
---|
718 | // fXMLVersion |
---|
719 | // Enum to indicate if the main doc is XML 1.1 or XML 1.0 conformant |
---|
720 | // fUIntPool |
---|
721 | // pool of unsigned integers to help with duplicate attribute |
---|
722 | // detection and filling in default/fixed attributes |
---|
723 | // fUIntPoolRow |
---|
724 | // current row in fUIntPool |
---|
725 | // fUIntPoolCol |
---|
726 | // current column i row |
---|
727 | // fUIntPoolRowTotal |
---|
728 | // total number of rows in table |
---|
729 | // |
---|
730 | // fMemoryManager |
---|
731 | // Pluggable memory manager for dynamic allocation/deallocation. |
---|
732 | // |
---|
733 | // ----------------------------------------------------------------------- |
---|
734 | size_t fBufferSize; |
---|
735 | bool fStandardUriConformant; |
---|
736 | bool fCalculateSrcOfs; |
---|
737 | bool fDoNamespaces; |
---|
738 | bool fExitOnFirstFatal; |
---|
739 | bool fValidationConstraintFatal; |
---|
740 | bool fInException; |
---|
741 | bool fStandalone; |
---|
742 | bool fHasNoDTD; |
---|
743 | bool fValidate; |
---|
744 | bool fValidatorFromUser; |
---|
745 | bool fDoSchema; |
---|
746 | bool fSchemaFullChecking; |
---|
747 | bool fIdentityConstraintChecking; |
---|
748 | bool fToCacheGrammar; |
---|
749 | bool fUseCachedGrammar; |
---|
750 | bool fLoadExternalDTD; |
---|
751 | bool fNormalizeData; |
---|
752 | bool fGenerateSyntheticAnnotations; |
---|
753 | bool fValidateAnnotations; |
---|
754 | bool fIgnoreCachedDTD; |
---|
755 | bool fIgnoreAnnotations; |
---|
756 | bool fDisableDefaultEntityResolution; |
---|
757 | bool fSkipDTDValidation; |
---|
758 | int fErrorCount; |
---|
759 | unsigned int fEntityExpansionLimit; |
---|
760 | unsigned int fEntityExpansionCount; |
---|
761 | unsigned int fEmptyNamespaceId; |
---|
762 | unsigned int fUnknownNamespaceId; |
---|
763 | unsigned int fXMLNamespaceId; |
---|
764 | unsigned int fXMLNSNamespaceId; |
---|
765 | unsigned int fSchemaNamespaceId; |
---|
766 | unsigned int ** fUIntPool; |
---|
767 | unsigned int fUIntPoolRow; |
---|
768 | unsigned int fUIntPoolCol; |
---|
769 | unsigned int fUIntPoolRowTotal; |
---|
770 | XMLUInt32 fScannerId; |
---|
771 | XMLUInt32 fSequenceId; |
---|
772 | RefVectorOf<XMLAttr>* fAttrList; |
---|
773 | RefHash2KeysTableOf<XMLAttr>* fAttrDupChkRegistry; |
---|
774 | XMLDocumentHandler* fDocHandler; |
---|
775 | DocTypeHandler* fDocTypeHandler; |
---|
776 | XMLEntityHandler* fEntityHandler; |
---|
777 | XMLErrorReporter* fErrorReporter; |
---|
778 | ErrorHandler* fErrorHandler; |
---|
779 | PSVIHandler* fPSVIHandler; |
---|
780 | ValidationContext *fValidationContext; |
---|
781 | bool fEntityDeclPoolRetrieved; |
---|
782 | ReaderMgr fReaderMgr; |
---|
783 | XMLValidator* fValidator; |
---|
784 | ValSchemes fValScheme; |
---|
785 | GrammarResolver* const fGrammarResolver; |
---|
786 | MemoryManager* const fGrammarPoolMemoryManager; |
---|
787 | Grammar* fGrammar; |
---|
788 | Grammar* fRootGrammar; |
---|
789 | XMLStringPool* fURIStringPool; |
---|
790 | XMLCh* fRootElemName; |
---|
791 | XMLCh* fExternalSchemaLocation; |
---|
792 | XMLCh* fExternalNoNamespaceSchemaLocation; |
---|
793 | SecurityManager* fSecurityManager; |
---|
794 | XMLReader::XMLVersion fXMLVersion; |
---|
795 | MemoryManager* fMemoryManager; |
---|
796 | XMLBufferMgr fBufMgr; |
---|
797 | XMLBuffer fAttNameBuf; |
---|
798 | XMLBuffer fAttValueBuf; |
---|
799 | XMLBuffer fCDataBuf; |
---|
800 | XMLBuffer fQNameBuf; |
---|
801 | XMLBuffer fPrefixBuf; |
---|
802 | XMLBuffer fURIBuf; |
---|
803 | XMLBuffer fWSNormalizeBuf; |
---|
804 | ElemStack fElemStack; |
---|
805 | |
---|
806 | |
---|
807 | private : |
---|
808 | // ----------------------------------------------------------------------- |
---|
809 | // Unimplemented constructors and operators |
---|
810 | // ----------------------------------------------------------------------- |
---|
811 | XMLScanner(); |
---|
812 | XMLScanner(const XMLScanner&); |
---|
813 | XMLScanner& operator=(const XMLScanner&); |
---|
814 | |
---|
815 | // ----------------------------------------------------------------------- |
---|
816 | // Private helper methods |
---|
817 | // ----------------------------------------------------------------------- |
---|
818 | void commonInit(); |
---|
819 | void cleanUp(); |
---|
820 | |
---|
821 | // ----------------------------------------------------------------------- |
---|
822 | // Private scanning methods |
---|
823 | // ----------------------------------------------------------------------- |
---|
824 | bool getQuotedString(XMLBuffer& toFill); |
---|
825 | unsigned int scanUpToWSOr |
---|
826 | ( |
---|
827 | XMLBuffer& toFill |
---|
828 | , const XMLCh chEndChar |
---|
829 | ); |
---|
830 | }; |
---|
831 | |
---|
832 | // --------------------------------------------------------------------------- |
---|
833 | // XMLScanner: Getter methods |
---|
834 | // --------------------------------------------------------------------------- |
---|
835 | inline const XMLDocumentHandler* XMLScanner::getDocHandler() const |
---|
836 | { |
---|
837 | return fDocHandler; |
---|
838 | } |
---|
839 | |
---|
840 | inline XMLDocumentHandler* XMLScanner::getDocHandler() |
---|
841 | { |
---|
842 | return fDocHandler; |
---|
843 | } |
---|
844 | |
---|
845 | inline const DocTypeHandler* XMLScanner::getDocTypeHandler() const |
---|
846 | { |
---|
847 | return fDocTypeHandler; |
---|
848 | } |
---|
849 | |
---|
850 | inline DocTypeHandler* XMLScanner::getDocTypeHandler() |
---|
851 | { |
---|
852 | return fDocTypeHandler; |
---|
853 | } |
---|
854 | |
---|
855 | inline bool XMLScanner::getDoNamespaces() const |
---|
856 | { |
---|
857 | return fDoNamespaces; |
---|
858 | } |
---|
859 | |
---|
860 | inline const XMLEntityHandler* XMLScanner::getEntityHandler() const |
---|
861 | { |
---|
862 | return fEntityHandler; |
---|
863 | } |
---|
864 | |
---|
865 | inline XMLEntityHandler* XMLScanner::getEntityHandler() |
---|
866 | { |
---|
867 | return fEntityHandler; |
---|
868 | } |
---|
869 | |
---|
870 | inline const XMLErrorReporter* XMLScanner::getErrorReporter() const |
---|
871 | { |
---|
872 | return fErrorReporter; |
---|
873 | } |
---|
874 | |
---|
875 | inline XMLErrorReporter* XMLScanner::getErrorReporter() |
---|
876 | { |
---|
877 | return fErrorReporter; |
---|
878 | } |
---|
879 | |
---|
880 | inline const ErrorHandler* XMLScanner::getErrorHandler() const |
---|
881 | { |
---|
882 | return fErrorHandler; |
---|
883 | } |
---|
884 | |
---|
885 | inline ErrorHandler* XMLScanner::getErrorHandler() |
---|
886 | { |
---|
887 | return fErrorHandler; |
---|
888 | } |
---|
889 | |
---|
890 | inline const PSVIHandler* XMLScanner::getPSVIHandler() const |
---|
891 | { |
---|
892 | return fPSVIHandler; |
---|
893 | } |
---|
894 | |
---|
895 | inline PSVIHandler* XMLScanner::getPSVIHandler() |
---|
896 | { |
---|
897 | return fPSVIHandler; |
---|
898 | } |
---|
899 | |
---|
900 | inline bool XMLScanner::getExitOnFirstFatal() const |
---|
901 | { |
---|
902 | return fExitOnFirstFatal; |
---|
903 | } |
---|
904 | |
---|
905 | inline bool XMLScanner::getValidationConstraintFatal() const |
---|
906 | { |
---|
907 | return fValidationConstraintFatal; |
---|
908 | } |
---|
909 | |
---|
910 | inline bool XMLScanner::getInException() const |
---|
911 | { |
---|
912 | return fInException; |
---|
913 | } |
---|
914 | |
---|
915 | inline RefHashTableOf<XMLRefInfo>* XMLScanner::getIDRefList() |
---|
916 | { |
---|
917 | return fValidationContext->getIdRefList(); |
---|
918 | } |
---|
919 | |
---|
920 | inline const RefHashTableOf<XMLRefInfo>* XMLScanner::getIDRefList() const |
---|
921 | { |
---|
922 | return fValidationContext->getIdRefList(); |
---|
923 | } |
---|
924 | |
---|
925 | inline ValidationContext* XMLScanner::getValidationContext() |
---|
926 | { |
---|
927 | if (!fEntityDeclPoolRetrieved) |
---|
928 | { |
---|
929 | fValidationContext->setEntityDeclPool(getEntityDeclPool()); |
---|
930 | fEntityDeclPoolRetrieved = true; |
---|
931 | } |
---|
932 | |
---|
933 | return fValidationContext; |
---|
934 | } |
---|
935 | |
---|
936 | inline const Locator* XMLScanner::getLocator() const |
---|
937 | { |
---|
938 | return &fReaderMgr; |
---|
939 | } |
---|
940 | |
---|
941 | inline const ReaderMgr* XMLScanner::getReaderMgr() const |
---|
942 | { |
---|
943 | return &fReaderMgr; |
---|
944 | } |
---|
945 | |
---|
946 | inline unsigned int XMLScanner::getSrcOffset() const |
---|
947 | { |
---|
948 | return fReaderMgr.getSrcOffset(); |
---|
949 | } |
---|
950 | |
---|
951 | inline bool XMLScanner::getStandalone() const |
---|
952 | { |
---|
953 | return fStandalone; |
---|
954 | } |
---|
955 | |
---|
956 | inline XMLScanner::ValSchemes XMLScanner::getValidationScheme() const |
---|
957 | { |
---|
958 | return fValScheme; |
---|
959 | } |
---|
960 | |
---|
961 | inline const XMLValidator* XMLScanner::getValidator() const |
---|
962 | { |
---|
963 | return fValidator; |
---|
964 | } |
---|
965 | |
---|
966 | inline XMLValidator* XMLScanner::getValidator() |
---|
967 | { |
---|
968 | return fValidator; |
---|
969 | } |
---|
970 | |
---|
971 | inline bool XMLScanner::getDoSchema() const |
---|
972 | { |
---|
973 | return fDoSchema; |
---|
974 | } |
---|
975 | |
---|
976 | inline bool XMLScanner::getValidationSchemaFullChecking() const |
---|
977 | { |
---|
978 | return fSchemaFullChecking; |
---|
979 | } |
---|
980 | |
---|
981 | inline bool XMLScanner::getIdentityConstraintChecking() const |
---|
982 | { |
---|
983 | return fIdentityConstraintChecking; |
---|
984 | } |
---|
985 | |
---|
986 | inline int XMLScanner::getErrorCount() |
---|
987 | { |
---|
988 | return fErrorCount; |
---|
989 | } |
---|
990 | |
---|
991 | inline bool XMLScanner::isValidatorFromUser() |
---|
992 | { |
---|
993 | return fValidatorFromUser; |
---|
994 | } |
---|
995 | |
---|
996 | inline unsigned int XMLScanner::getEmptyNamespaceId() const |
---|
997 | { |
---|
998 | return fEmptyNamespaceId; |
---|
999 | } |
---|
1000 | |
---|
1001 | inline unsigned int XMLScanner::getUnknownNamespaceId() const |
---|
1002 | { |
---|
1003 | return fUnknownNamespaceId; |
---|
1004 | } |
---|
1005 | |
---|
1006 | inline unsigned int XMLScanner::getXMLNamespaceId() const |
---|
1007 | { |
---|
1008 | return fXMLNamespaceId; |
---|
1009 | } |
---|
1010 | |
---|
1011 | inline unsigned int XMLScanner::getXMLNSNamespaceId() const |
---|
1012 | { |
---|
1013 | return fXMLNSNamespaceId; |
---|
1014 | } |
---|
1015 | |
---|
1016 | inline const XMLStringPool* XMLScanner::getURIStringPool() const |
---|
1017 | { |
---|
1018 | return fURIStringPool; |
---|
1019 | } |
---|
1020 | |
---|
1021 | inline XMLStringPool* XMLScanner::getURIStringPool() |
---|
1022 | { |
---|
1023 | return fURIStringPool; |
---|
1024 | } |
---|
1025 | |
---|
1026 | inline bool XMLScanner::getHasNoDTD() const |
---|
1027 | { |
---|
1028 | return fHasNoDTD; |
---|
1029 | } |
---|
1030 | |
---|
1031 | inline XMLCh* XMLScanner::getExternalSchemaLocation() const |
---|
1032 | { |
---|
1033 | return fExternalSchemaLocation; |
---|
1034 | } |
---|
1035 | |
---|
1036 | inline XMLCh* XMLScanner::getExternalNoNamespaceSchemaLocation() const |
---|
1037 | { |
---|
1038 | return fExternalNoNamespaceSchemaLocation; |
---|
1039 | } |
---|
1040 | |
---|
1041 | inline SecurityManager* XMLScanner::getSecurityManager() const |
---|
1042 | { |
---|
1043 | return fSecurityManager; |
---|
1044 | } |
---|
1045 | |
---|
1046 | inline bool XMLScanner::getLoadExternalDTD() const |
---|
1047 | { |
---|
1048 | return fLoadExternalDTD; |
---|
1049 | } |
---|
1050 | |
---|
1051 | inline bool XMLScanner::getNormalizeData() const |
---|
1052 | { |
---|
1053 | return fNormalizeData; |
---|
1054 | } |
---|
1055 | |
---|
1056 | inline bool XMLScanner::isCachingGrammarFromParse() const |
---|
1057 | { |
---|
1058 | return fToCacheGrammar; |
---|
1059 | } |
---|
1060 | |
---|
1061 | inline bool XMLScanner::isUsingCachedGrammarInParse() const |
---|
1062 | { |
---|
1063 | return fUseCachedGrammar; |
---|
1064 | } |
---|
1065 | |
---|
1066 | inline bool XMLScanner::getCalculateSrcOfs() const |
---|
1067 | { |
---|
1068 | return fCalculateSrcOfs; |
---|
1069 | } |
---|
1070 | |
---|
1071 | inline Grammar* XMLScanner::getRootGrammar() const |
---|
1072 | { |
---|
1073 | return fRootGrammar; |
---|
1074 | } |
---|
1075 | |
---|
1076 | inline bool XMLScanner::getStandardUriConformant() const |
---|
1077 | { |
---|
1078 | return fStandardUriConformant; |
---|
1079 | } |
---|
1080 | |
---|
1081 | inline XMLReader::XMLVersion XMLScanner::getXMLVersion() const |
---|
1082 | { |
---|
1083 | return fXMLVersion; |
---|
1084 | } |
---|
1085 | |
---|
1086 | inline MemoryManager* XMLScanner::getMemoryManager() const |
---|
1087 | { |
---|
1088 | return fMemoryManager; |
---|
1089 | } |
---|
1090 | |
---|
1091 | inline ValueVectorOf<PrefMapElem*>* XMLScanner::getNamespaceContext() const |
---|
1092 | { |
---|
1093 | return fElemStack.getNamespaceMap(); |
---|
1094 | } |
---|
1095 | |
---|
1096 | inline unsigned int XMLScanner::getPrefixId(const XMLCh* const prefix) const |
---|
1097 | { |
---|
1098 | return fElemStack.getPrefixId(prefix); |
---|
1099 | } |
---|
1100 | |
---|
1101 | inline const XMLCh* XMLScanner::getPrefixForId(unsigned int prefId) const |
---|
1102 | { |
---|
1103 | return fElemStack.getPrefixForId(prefId); |
---|
1104 | } |
---|
1105 | |
---|
1106 | inline bool XMLScanner::getGenerateSyntheticAnnotations() const |
---|
1107 | { |
---|
1108 | return fGenerateSyntheticAnnotations; |
---|
1109 | } |
---|
1110 | |
---|
1111 | inline bool XMLScanner::getValidateAnnotations() const |
---|
1112 | { |
---|
1113 | return fValidateAnnotations; |
---|
1114 | } |
---|
1115 | |
---|
1116 | inline bool XMLScanner::getIgnoreCachedDTD() const |
---|
1117 | { |
---|
1118 | return fIgnoreCachedDTD; |
---|
1119 | } |
---|
1120 | |
---|
1121 | inline bool XMLScanner::getIgnoreAnnotations() const |
---|
1122 | { |
---|
1123 | return fIgnoreAnnotations; |
---|
1124 | } |
---|
1125 | |
---|
1126 | inline bool XMLScanner::getDisableDefaultEntityResolution() const |
---|
1127 | { |
---|
1128 | return fDisableDefaultEntityResolution; |
---|
1129 | } |
---|
1130 | |
---|
1131 | inline bool XMLScanner::getSkipDTDValidation() const |
---|
1132 | { |
---|
1133 | return fSkipDTDValidation; |
---|
1134 | } |
---|
1135 | |
---|
1136 | // --------------------------------------------------------------------------- |
---|
1137 | // XMLScanner: Setter methods |
---|
1138 | // --------------------------------------------------------------------------- |
---|
1139 | inline void XMLScanner::setDocHandler(XMLDocumentHandler* const docHandler) |
---|
1140 | { |
---|
1141 | fDocHandler = docHandler; |
---|
1142 | } |
---|
1143 | |
---|
1144 | inline void XMLScanner::setDocTypeHandler(DocTypeHandler* const docTypeHandler) |
---|
1145 | { |
---|
1146 | fDocTypeHandler = docTypeHandler; |
---|
1147 | } |
---|
1148 | |
---|
1149 | inline void XMLScanner::setErrorHandler(ErrorHandler* const handler) |
---|
1150 | { |
---|
1151 | fErrorHandler = handler; |
---|
1152 | } |
---|
1153 | |
---|
1154 | inline void XMLScanner::setPSVIHandler(PSVIHandler* const handler) |
---|
1155 | { |
---|
1156 | fPSVIHandler = handler; |
---|
1157 | } |
---|
1158 | |
---|
1159 | inline void XMLScanner::setEntityHandler(XMLEntityHandler* const entityHandler) |
---|
1160 | { |
---|
1161 | fEntityHandler = entityHandler; |
---|
1162 | fReaderMgr.setEntityHandler(entityHandler); |
---|
1163 | } |
---|
1164 | |
---|
1165 | inline void XMLScanner::setErrorReporter(XMLErrorReporter* const errHandler) |
---|
1166 | { |
---|
1167 | fErrorReporter = errHandler; |
---|
1168 | } |
---|
1169 | |
---|
1170 | inline void XMLScanner::setExitOnFirstFatal(const bool newValue) |
---|
1171 | { |
---|
1172 | fExitOnFirstFatal = newValue; |
---|
1173 | } |
---|
1174 | |
---|
1175 | |
---|
1176 | inline void XMLScanner::setValidationConstraintFatal(const bool newValue) |
---|
1177 | { |
---|
1178 | fValidationConstraintFatal = newValue; |
---|
1179 | } |
---|
1180 | |
---|
1181 | inline void XMLScanner::setValidationScheme(const ValSchemes newScheme) |
---|
1182 | { |
---|
1183 | fValScheme = newScheme; |
---|
1184 | |
---|
1185 | // validation flag for Val_Auto is set to false by default, |
---|
1186 | // and will be turned to true if a grammar is seen |
---|
1187 | if (fValScheme == Val_Always) |
---|
1188 | fValidate = true; |
---|
1189 | else |
---|
1190 | fValidate = false; |
---|
1191 | } |
---|
1192 | |
---|
1193 | inline void XMLScanner::setDoSchema(const bool doSchema) |
---|
1194 | { |
---|
1195 | fDoSchema = doSchema; |
---|
1196 | } |
---|
1197 | |
---|
1198 | inline void XMLScanner::setDoNamespaces(const bool doNamespaces) |
---|
1199 | { |
---|
1200 | fDoNamespaces = doNamespaces; |
---|
1201 | } |
---|
1202 | |
---|
1203 | inline void XMLScanner::setValidationSchemaFullChecking(const bool schemaFullChecking) |
---|
1204 | { |
---|
1205 | fSchemaFullChecking = schemaFullChecking; |
---|
1206 | } |
---|
1207 | |
---|
1208 | inline void XMLScanner::setIdentityConstraintChecking(const bool identityConstraintChecking) |
---|
1209 | { |
---|
1210 | fIdentityConstraintChecking = identityConstraintChecking; |
---|
1211 | } |
---|
1212 | |
---|
1213 | inline void XMLScanner::setHasNoDTD(const bool hasNoDTD) |
---|
1214 | { |
---|
1215 | fHasNoDTD = hasNoDTD; |
---|
1216 | } |
---|
1217 | |
---|
1218 | inline void XMLScanner::setRootElemName(XMLCh* rootElemName) |
---|
1219 | { |
---|
1220 | fMemoryManager->deallocate(fRootElemName);//delete [] fRootElemName; |
---|
1221 | fRootElemName = XMLString::replicate(rootElemName, fMemoryManager); |
---|
1222 | } |
---|
1223 | |
---|
1224 | inline void XMLScanner::setExternalSchemaLocation(const XMLCh* const schemaLocation) |
---|
1225 | { |
---|
1226 | fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation; |
---|
1227 | fExternalSchemaLocation = XMLString::replicate(schemaLocation, fMemoryManager); |
---|
1228 | } |
---|
1229 | |
---|
1230 | inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const XMLCh* const noNamespaceSchemaLocation) |
---|
1231 | { |
---|
1232 | fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation; |
---|
1233 | fExternalNoNamespaceSchemaLocation = XMLString::replicate(noNamespaceSchemaLocation, fMemoryManager); |
---|
1234 | } |
---|
1235 | |
---|
1236 | inline void XMLScanner::setExternalSchemaLocation(const char* const schemaLocation) |
---|
1237 | { |
---|
1238 | fMemoryManager->deallocate(fExternalSchemaLocation);//delete [] fExternalSchemaLocation; |
---|
1239 | fExternalSchemaLocation = XMLString::transcode(schemaLocation, fMemoryManager); |
---|
1240 | } |
---|
1241 | |
---|
1242 | inline void XMLScanner::setExternalNoNamespaceSchemaLocation(const char* const noNamespaceSchemaLocation) |
---|
1243 | { |
---|
1244 | fMemoryManager->deallocate(fExternalNoNamespaceSchemaLocation);//delete [] fExternalNoNamespaceSchemaLocation; |
---|
1245 | fExternalNoNamespaceSchemaLocation = XMLString::transcode(noNamespaceSchemaLocation, fMemoryManager); |
---|
1246 | } |
---|
1247 | |
---|
1248 | inline void XMLScanner::setSecurityManager(SecurityManager* const securityManager) |
---|
1249 | { |
---|
1250 | fSecurityManager = securityManager; |
---|
1251 | if(securityManager != 0) |
---|
1252 | { |
---|
1253 | fEntityExpansionLimit = securityManager->getEntityExpansionLimit(); |
---|
1254 | fEntityExpansionCount = 0; |
---|
1255 | } |
---|
1256 | } |
---|
1257 | |
---|
1258 | inline void XMLScanner::setLoadExternalDTD(const bool loadDTD) |
---|
1259 | { |
---|
1260 | fLoadExternalDTD = loadDTD; |
---|
1261 | } |
---|
1262 | |
---|
1263 | inline void XMLScanner::setNormalizeData(const bool normalizeData) |
---|
1264 | { |
---|
1265 | fNormalizeData = normalizeData; |
---|
1266 | } |
---|
1267 | |
---|
1268 | inline void XMLScanner::cacheGrammarFromParse(const bool newValue) |
---|
1269 | { |
---|
1270 | fToCacheGrammar = newValue; |
---|
1271 | } |
---|
1272 | |
---|
1273 | inline void XMLScanner::useCachedGrammarInParse(const bool newValue) |
---|
1274 | { |
---|
1275 | fUseCachedGrammar = newValue; |
---|
1276 | } |
---|
1277 | |
---|
1278 | inline void XMLScanner::setCalculateSrcOfs(const bool newValue) |
---|
1279 | { |
---|
1280 | fCalculateSrcOfs = newValue; |
---|
1281 | } |
---|
1282 | |
---|
1283 | inline void XMLScanner::setStandardUriConformant(const bool newValue) |
---|
1284 | { |
---|
1285 | fStandardUriConformant = newValue; |
---|
1286 | fReaderMgr.setStandardUriConformant(newValue); |
---|
1287 | } |
---|
1288 | |
---|
1289 | inline void XMLScanner::setGenerateSyntheticAnnotations(const bool newValue) |
---|
1290 | { |
---|
1291 | fGenerateSyntheticAnnotations = newValue; |
---|
1292 | } |
---|
1293 | |
---|
1294 | inline void XMLScanner::setValidateAnnotations(const bool newValue) |
---|
1295 | { |
---|
1296 | fValidateAnnotations = newValue; |
---|
1297 | } |
---|
1298 | |
---|
1299 | inline void XMLScanner::setInputBufferSize(const size_t bufferSize) |
---|
1300 | { |
---|
1301 | fBufferSize = bufferSize; |
---|
1302 | fCDataBuf.setFullHandler(this, (unsigned int)fBufferSize); |
---|
1303 | } |
---|
1304 | |
---|
1305 | inline void XMLScanner::setIgnoredCachedDTD(const bool newValue) |
---|
1306 | { |
---|
1307 | fIgnoreCachedDTD = newValue; |
---|
1308 | } |
---|
1309 | |
---|
1310 | inline void XMLScanner::setIgnoreAnnotations(const bool newValue) |
---|
1311 | { |
---|
1312 | fIgnoreAnnotations = newValue; |
---|
1313 | } |
---|
1314 | |
---|
1315 | inline void XMLScanner::setDisableDefaultEntityResolution(const bool newValue) |
---|
1316 | { |
---|
1317 | fDisableDefaultEntityResolution = newValue; |
---|
1318 | } |
---|
1319 | |
---|
1320 | inline void XMLScanner::setSkipDTDValidation(const bool newValue) |
---|
1321 | { |
---|
1322 | fSkipDTDValidation = newValue; |
---|
1323 | } |
---|
1324 | |
---|
1325 | // --------------------------------------------------------------------------- |
---|
1326 | // XMLScanner: Mutator methods |
---|
1327 | // --------------------------------------------------------------------------- |
---|
1328 | inline void XMLScanner::incrementErrorCount() |
---|
1329 | { |
---|
1330 | ++fErrorCount; |
---|
1331 | } |
---|
1332 | |
---|
1333 | // --------------------------------------------------------------------------- |
---|
1334 | // XMLScanner: Deprecated methods |
---|
1335 | // --------------------------------------------------------------------------- |
---|
1336 | inline bool XMLScanner::getDoValidation() const |
---|
1337 | { |
---|
1338 | return fValidate; |
---|
1339 | } |
---|
1340 | |
---|
1341 | inline void XMLScanner::setDoValidation(const bool validate) |
---|
1342 | { |
---|
1343 | fValidate = validate; |
---|
1344 | if (fValidate) |
---|
1345 | fValScheme = Val_Always; |
---|
1346 | else |
---|
1347 | fValScheme = Val_Never; |
---|
1348 | } |
---|
1349 | |
---|
1350 | inline void XMLScanner::resetValidationContext() |
---|
1351 | { |
---|
1352 | fValidationContext->clearIdRefList(); |
---|
1353 | fValidationContext->setEntityDeclPool(0); |
---|
1354 | fEntityDeclPoolRetrieved = false; |
---|
1355 | } |
---|
1356 | |
---|
1357 | inline void XMLScanner::setAttrDupChkRegistry(const unsigned int &attrNumber |
---|
1358 | , bool &toUseHashTable) |
---|
1359 | { |
---|
1360 | // once the attribute exceed 100, we use hash table to check duplication |
---|
1361 | if (attrNumber > 100) |
---|
1362 | { |
---|
1363 | toUseHashTable = true; |
---|
1364 | |
---|
1365 | if (!fAttrDupChkRegistry) |
---|
1366 | { |
---|
1367 | fAttrDupChkRegistry = new (fMemoryManager) RefHash2KeysTableOf<XMLAttr> |
---|
1368 | ( |
---|
1369 | 2*attrNumber+1, false, new (fMemoryManager)HashXMLCh(), fMemoryManager |
---|
1370 | ); |
---|
1371 | } |
---|
1372 | else |
---|
1373 | { |
---|
1374 | fAttrDupChkRegistry->removeAll(); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | |
---|
1378 | } |
---|
1379 | |
---|
1380 | inline Grammar::GrammarType XMLScanner::getCurrentGrammarType() const |
---|
1381 | { |
---|
1382 | return Grammar::UnKnown; |
---|
1383 | } |
---|
1384 | |
---|
1385 | XERCES_CPP_NAMESPACE_END |
---|
1386 | |
---|
1387 | #endif |
---|