|
||||
File indexing completed on 2025-01-18 10:14:57
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_SAX2XMLREADERIMPL_HPP) 0023 #define XERCESC_INCLUDE_GUARD_SAX2XMLREADERIMPL_HPP 0024 0025 #include <xercesc/parsers/SAXParser.hpp> 0026 #include <xercesc/sax/Parser.hpp> 0027 #include <xercesc/framework/XMLBuffer.hpp> 0028 #include <xercesc/internal/VecAttributesImpl.hpp> 0029 #include <xercesc/sax2/SAX2XMLReader.hpp> 0030 #include <xercesc/util/RefStackOf.hpp> 0031 #include <xercesc/util/SecurityManager.hpp> 0032 #include <xercesc/util/ValueStackOf.hpp> 0033 0034 XERCES_CPP_NAMESPACE_BEGIN 0035 0036 0037 class ContentHandler; 0038 class LexicalHandler; 0039 class DeclHandler; 0040 class GrammarResolver; 0041 class XMLGrammarPool; 0042 class XMLResourceIdentifier; 0043 class PSVIHandler; 0044 0045 /** 0046 * This class implements the SAX2 'XMLReader' interface and should be 0047 * used by applications wishing to parse the XML files using SAX2. 0048 * It allows the client program to install SAX2 handlers for event 0049 * callbacks. 0050 * 0051 * <p>It can be used to instantiate a validating or non-validating 0052 * parser, by setting a member flag.</p> 0053 * 0054 * we basically re-use the existing SAX1 parser code, but provide a 0055 * new implementation of XMLContentHandler that raises the new 0056 * SAX2 style events 0057 * 0058 */ 0059 0060 class PARSERS_EXPORT SAX2XMLReaderImpl : 0061 public XMemory 0062 , public SAX2XMLReader 0063 , public XMLDocumentHandler 0064 , public XMLErrorReporter 0065 , public XMLEntityHandler 0066 , public DocTypeHandler 0067 { 0068 public : 0069 // ----------------------------------------------------------------------- 0070 // Constructors and Destructor 0071 // ----------------------------------------------------------------------- 0072 /** @name Constructors and Destructor */ 0073 //@{ 0074 /** The default constructor */ 0075 SAX2XMLReaderImpl( 0076 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager 0077 , XMLGrammarPool* const gramPool = 0 0078 ); 0079 0080 /** The destructor */ 0081 ~SAX2XMLReaderImpl() ; 0082 //@} 0083 0084 //----------------------------------------------------------------------- 0085 // Implementation of SAX2XMLReader Interface 0086 //----------------------------------------------------------------------- 0087 //----------------------------------------------------------------------- 0088 // The XMLReader interface 0089 //----------------------------------------------------------------------- 0090 /** @name Implementation of SAX 2.0 XMLReader interface's. */ 0091 //@{ 0092 0093 /** 0094 * This method returns the installed content handler. 0095 * 0096 * @return A pointer to the installed content handler object. 0097 */ 0098 virtual ContentHandler* getContentHandler() const ; 0099 0100 /** 0101 * This method returns the installed DTD handler. 0102 * 0103 * @return A pointer to the installed DTD handler object. 0104 */ 0105 virtual DTDHandler* getDTDHandler() const ; 0106 0107 /** 0108 * This method returns the installed entity resolver. 0109 * 0110 * @return A pointer to the installed entity resolver object. 0111 */ 0112 virtual EntityResolver* getEntityResolver() const ; 0113 0114 /** 0115 * This method returns the installed entity resolver. 0116 * 0117 * @return A pointer to the installed entity resolver object. 0118 */ 0119 virtual XMLEntityResolver* getXMLEntityResolver() const ; 0120 0121 /** 0122 * This method returns the installed error handler. 0123 * 0124 * @return A pointer to the installed error handler object. 0125 */ 0126 virtual ErrorHandler* getErrorHandler() const ; 0127 0128 /** 0129 * This method returns the installed PSVI handler. 0130 * 0131 * @return A pointer to the installed PSVI handler object. 0132 */ 0133 virtual PSVIHandler* getPSVIHandler() const ; 0134 0135 /** 0136 * Query the current state of any feature in a SAX2 XMLReader. 0137 * 0138 * @param name The unique identifier (URI) of the feature being set. 0139 * @return The current state of the feature. 0140 * @exception SAXNotRecognizedException If the requested feature is not known. 0141 */ 0142 virtual bool getFeature(const XMLCh* const name) const ; 0143 0144 /** 0145 * Query the current value of a property in a SAX2 XMLReader. 0146 * 0147 * The parser owns the returned pointer. The memory allocated for 0148 * the returned pointer will be destroyed when the parser is deleted. 0149 * 0150 * To ensure accessibility of the returned information after the parser 0151 * is deleted, callers need to copy and store the returned information 0152 * somewhere else; otherwise you may get unexpected result. Since the returned 0153 * pointer is a generic void pointer, see the SAX2 Programming Guide to learn 0154 * exactly what type of property value each property returns for replication. 0155 * 0156 * @param name The unique identifier (URI) of the property being set. 0157 * @return The current value of the property. The pointer spans the same 0158 * life-time as the parser. A null pointer is returned if nothing 0159 * was specified externally. 0160 * @exception SAXNotRecognizedException If the requested property is not known. 0161 */ 0162 virtual void* getProperty(const XMLCh* const name) const ; 0163 0164 /** 0165 * Allow an application to register a document event handler. 0166 * 0167 * If the application does not register a document handler, all 0168 * document events reported by the SAX parser will be silently 0169 * ignored (this is the default behaviour implemented by 0170 * HandlerBase). 0171 * 0172 * Applications may register a new or different handler in the 0173 * middle of a parse, and the SAX parser must begin using the new 0174 * handler immediately. 0175 * 0176 * @param handler The document handler. 0177 * @see DocumentHandler#DocumentHandler 0178 * @see HandlerBase#HandlerBase 0179 */ 0180 virtual void setContentHandler(ContentHandler* const handler) ; 0181 0182 /** 0183 * Allow an application to register a DTD event handler. 0184 * 0185 * If the application does not register a DTD handler, all DTD 0186 * events reported by the SAX parser will be silently ignored (this 0187 * is the default behaviour implemented by HandlerBase). 0188 * 0189 * Applications may register a new or different handler in the middle 0190 * of a parse, and the SAX parser must begin using the new handler 0191 * immediately. 0192 * 0193 * @param handler The DTD handler. 0194 * @see DTDHandler#DTDHandler 0195 * @see HandlerBase#HandlerBase 0196 */ 0197 virtual void setDTDHandler(DTDHandler* const handler) ; 0198 0199 /** 0200 * Allow an application to register a custom entity resolver. 0201 * 0202 * If the application does not register an entity resolver, the 0203 * SAX parser will resolve system identifiers and open connections 0204 * to entities itself (this is the default behaviour implemented in 0205 * DefaultHandler). 0206 * 0207 * Applications may register a new or different entity resolver 0208 * in the middle of a parse, and the SAX parser must begin using 0209 * the new resolver immediately. 0210 * 0211 * <i>Any previously set entity resolver is merely dropped, since the parser 0212 * does not own them. If both setEntityResolver and setXMLEntityResolver 0213 * are called, then the last one is used.</i> 0214 * 0215 * @param resolver The object for resolving entities. 0216 * @see EntityResolver#EntityResolver 0217 * @see DefaultHandler#DefaultHandler 0218 */ 0219 virtual void setEntityResolver(EntityResolver* const resolver) ; 0220 0221 /** Set the entity resolver 0222 * 0223 * This method allows applications to install their own entity 0224 * resolver. By installing an entity resolver, the applications 0225 * can trap and potentially redirect references to external 0226 * entities. 0227 * 0228 * <i>Any previously set entity resolver is merely dropped, since the parser 0229 * does not own them. If both setEntityResolver and setXMLEntityResolver 0230 * are called, then the last one is used.</i> 0231 * 0232 * @param resolver A const pointer to the user supplied entity 0233 * resolver. 0234 * 0235 * @see #getXMLEntityResolver 0236 */ 0237 virtual void setXMLEntityResolver(XMLEntityResolver* const resolver) ; 0238 0239 /** 0240 * Allow an application to register an error event handler. 0241 * 0242 * If the application does not register an error event handler, 0243 * all error events reported by the SAX parser will be silently 0244 * ignored, except for fatalError, which will throw a SAXException 0245 * (this is the default behaviour implemented by HandlerBase). 0246 * 0247 * Applications may register a new or different handler in the 0248 * middle of a parse, and the SAX parser must begin using the new 0249 * handler immediately. 0250 * 0251 * @param handler The error handler. 0252 * @see ErrorHandler#ErrorHandler 0253 * @see SAXException#SAXException 0254 * @see HandlerBase#HandlerBase 0255 */ 0256 virtual void setErrorHandler(ErrorHandler* const handler) ; 0257 0258 /** 0259 * This method installs the user specified PSVI handler on 0260 * the parser. 0261 * 0262 * @param handler A pointer to the PSVI handler to be called 0263 * when the parser comes across 'PSVI' events 0264 * as per the schema specification. 0265 */ 0266 virtual void setPSVIHandler(PSVIHandler* const handler); 0267 0268 /** 0269 * Set the state of any feature in a SAX2 XMLReader. 0270 * Supported features in SAX2 for xerces-c are: 0271 * <br>(See the SAX2 Programming Guide for detail description). 0272 * 0273 * <br>http://xml.org/sax/features/validation (default: false) 0274 * <br>http://xml.org/sax/features/namespaces (default: true) 0275 * <br>http://xml.org/sax/features/namespace-prefixes (default: false) 0276 * <br>http://apache.org/xml/features/validation/dynamic (default: false) 0277 * <br>http://apache.org/xml/features/validation/reuse-grammar (default: false) 0278 * <br>http://apache.org/xml/features/validation/schema (default: true) 0279 * <br>http://apache.org/xml/features/validation/schema-full-checking (default: false) 0280 * <br>http://apache.org/xml/features/validating/load-schema (default: true) 0281 * <br>http://apache.org/xml/features/nonvalidating/load-external-dtd (default: true) 0282 * <br>http://apache.org/xml/features/continue-after-fatal-error (default: false) 0283 * <br>http://apache.org/xml/features/validation-error-as-fatal (default: false) 0284 * 0285 * @param name The unique identifier (URI) of the feature. 0286 * @param value The requested state of the feature (true or false). 0287 * @exception SAXNotRecognizedException If the requested feature is not known. 0288 * @exception SAXNotSupportedException Feature modification is not supported during parse 0289 * 0290 */ 0291 virtual void setFeature(const XMLCh* const name, const bool value) ; 0292 0293 /** 0294 * Set the value of any property in a SAX2 XMLReader. 0295 * Supported properties in SAX2 for xerces-c are: 0296 * <br>(See the SAX2 Programming Guide for detail description). 0297 * 0298 * <br>http://apache.org/xml/properties/schema/external-schemaLocation 0299 * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation. 0300 * 0301 * It takes a void pointer as the property value. Application is required to initialize this void 0302 * pointer to a correct type. See the SAX2 Programming Guide 0303 * to learn exactly what type of property value each property expects for processing. 0304 * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. 0305 * If the same property is set more than once, the last one takes effect. 0306 * 0307 * @param name The unique identifier (URI) of the property being set. 0308 * @param value The requested value for the property. See 0309 * the SAX2 Programming Guide to learn 0310 * exactly what type of property value each property expects for processing. 0311 * Passing a void pointer that was initialized with a wrong type will lead 0312 * to unexpected result. 0313 * @exception SAXNotRecognizedException If the requested property is not known. 0314 * @exception SAXNotSupportedException Property modification is not supported during parse 0315 */ 0316 virtual void setProperty(const XMLCh* const name, void* value) ; 0317 0318 /** 0319 * Parse an XML document. 0320 * 0321 * The application can use this method to instruct the SAX parser 0322 * to begin parsing an XML document from any valid input 0323 * source (a character stream, a byte stream, or a URI). 0324 * 0325 * Applications may not invoke this method while a parse is in 0326 * progress (they should create a new Parser instead for each 0327 * additional XML document). Once a parse is complete, an 0328 * application may reuse the same Parser object, possibly with a 0329 * different input source. 0330 * 0331 * @param source The input source for the top-level of the 0332 * XML document. 0333 * @exception SAXException Any SAX exception, possibly 0334 * wrapping another exception. 0335 * @exception XMLException An exception from the parser or client 0336 * handler code. 0337 * @see InputSource#InputSource 0338 * @see #setEntityResolver 0339 * @see #setDTDHandler 0340 * @see #setDocumentHandler 0341 * @see #setErrorHandler 0342 */ 0343 virtual void parse 0344 ( 0345 const InputSource& source 0346 ) ; 0347 0348 /** 0349 * Parse an XML document from a system identifier (URI). 0350 * 0351 * This method is a shortcut for the common case of reading a 0352 * document from a system identifier. It is the exact equivalent 0353 * of the following: 0354 * 0355 * parse(new URLInputSource(systemId)); 0356 * 0357 * If the system identifier is a URL, it must be fully resolved 0358 * by the application before it is passed to the parser. 0359 * 0360 * @param systemId The system identifier (URI). 0361 * @exception SAXException Any SAX exception, possibly 0362 * wrapping another exception. 0363 * @exception XMLException An exception from the parser or client 0364 * handler code. 0365 * @see #parse(InputSource) 0366 */ 0367 virtual void parse 0368 ( 0369 const XMLCh* const systemId 0370 ) ; 0371 0372 /** 0373 * Parse an XML document from a system identifier (URI). 0374 * 0375 * This method is a shortcut for the common case of reading a 0376 * document from a system identifier. It is the exact equivalent 0377 * of the following: 0378 * 0379 * parse(new URLInputSource(systemId)); 0380 * 0381 * If the system identifier is a URL, it must be fully resolved 0382 * by the application before it is passed to the parser. 0383 * 0384 * @param systemId The system identifier (URI). 0385 * @exception SAXException Any SAX exception, possibly 0386 * wrapping another exception. 0387 * @exception XMLException An exception from the parser or client 0388 * handler code. 0389 * @see #parse(InputSource) 0390 */ 0391 virtual void parse 0392 ( 0393 const char* const systemId 0394 ) ; 0395 0396 //@} 0397 0398 // ----------------------------------------------------------------------- 0399 // SAX 2.0-ext 0400 // ----------------------------------------------------------------------- 0401 /** @name SAX 2.0-ext */ 0402 //@{ 0403 /** 0404 * This method returns the installed declaration handler. 0405 * 0406 * @return A pointer to the installed declaration handler object. 0407 */ 0408 virtual DeclHandler* getDeclarationHandler() const ; 0409 0410 /** 0411 * This method returns the installed lexical handler. 0412 * 0413 * @return A pointer to the installed lexical handler object. 0414 */ 0415 virtual LexicalHandler* getLexicalHandler() const ; 0416 0417 /** 0418 * Allow an application to register a declaration event handler. 0419 * 0420 * If the application does not register a declaration handler, 0421 * all events reported by the SAX parser will be silently 0422 * ignored. (this is the default behaviour implemented by DefaultHandler). 0423 * 0424 * Applications may register a new or different handler in the 0425 * middle of a parse, and the SAX parser must begin using the new 0426 * handler immediately. 0427 * 0428 * @param handler The DTD declaration handler. 0429 * @see DeclHandler#DeclHandler 0430 * @see SAXException#SAXException 0431 * @see DefaultHandler#DefaultHandler 0432 */ 0433 virtual void setDeclarationHandler(DeclHandler* const handler) ; 0434 0435 /** 0436 * Allow an application to register a lexical event handler. 0437 * 0438 * If the application does not register a lexical handler, 0439 * all events reported by the SAX parser will be silently 0440 * ignored. (this is the default behaviour implemented by HandlerBase). 0441 * 0442 * Applications may register a new or different handler in the 0443 * middle of a parse, and the SAX parser must begin using the new 0444 * handler immediately. 0445 * 0446 * @param handler The error handler. 0447 * @see LexicalHandler#LexicalHandler 0448 * @see SAXException#SAXException 0449 * @see HandlerBase#HandlerBase 0450 */ 0451 virtual void setLexicalHandler(LexicalHandler* const handler) ; 0452 0453 //@} 0454 0455 // ----------------------------------------------------------------------- 0456 // Getter Methods 0457 // ----------------------------------------------------------------------- 0458 /** @name Getter Methods (Xerces-C specific) */ 0459 //@{ 0460 /** 0461 * This method is used to get the current validator. 0462 * 0463 * <b>SAX2XMLReader assumes responsibility for the validator. It will be 0464 * deleted when the XMLReader is destroyed.</b> 0465 * 0466 * @return A pointer to the validator. An application should not deleted 0467 * the object returned. 0468 * 0469 */ 0470 virtual XMLValidator* getValidator() const ; 0471 //@} 0472 0473 /** Get error count from the last parse operation. 0474 * 0475 * This method returns the error count from the last parse 0476 * operation. Note that this count is actually stored in the 0477 * scanner, so this method simply returns what the 0478 * scanner reports. 0479 * 0480 * @return number of errors encountered during the latest 0481 * parse operation. 0482 */ 0483 virtual XMLSize_t getErrorCount() const ; 0484 0485 /** 0486 * This method returns the state of the parser's 0487 * exit-on-First-Fatal-Error flag. 0488 * 0489 * <p>Or you can query the feature "http://apache.org/xml/features/continue-after-fatal-error" 0490 * which indicates the opposite state.</p> 0491 * 0492 * @return true, if the parser is currently configured to 0493 * exit on the first fatal error, false otherwise. 0494 * 0495 * @see #setExitOnFirstFatalError 0496 * @see #getFeature 0497 */ 0498 virtual bool getExitOnFirstFatalError() const ; 0499 0500 /** 0501 * This method returns the state of the parser's 0502 * validation-constraint-fatal flag. 0503 * 0504 * <p>Or you can query the feature "http://apache.org/xml/features/validation-error-as-fatal" 0505 * which means the same thing. 0506 * 0507 * @return true, if the parser is currently configured to 0508 * set validation constraint errors as fatal, false 0509 * otherwise. 0510 * 0511 * @see #setValidationContraintFatal 0512 * @see #getFeature 0513 */ 0514 virtual bool getValidationConstraintFatal() const ; 0515 0516 /** 0517 * Retrieve the grammar that is associated with the specified namespace key 0518 * 0519 * @param nameSpaceKey Namespace key 0520 * @return Grammar associated with the Namespace key. 0521 */ 0522 virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey); 0523 0524 /** 0525 * Retrieve the grammar where the root element is declared. 0526 * 0527 * @return Grammar where root element declared 0528 */ 0529 virtual Grammar* getRootGrammar(); 0530 0531 /** 0532 * Returns the string corresponding to a URI id from the URI string pool. 0533 * 0534 * @param uriId id of the string in the URI string pool. 0535 * @return URI string corresponding to the URI id. 0536 */ 0537 virtual const XMLCh* getURIText(unsigned int uriId) const; 0538 0539 /** 0540 * Returns the current src offset within the input source. 0541 * To be used only while parsing is in progress. 0542 * 0543 * @return offset within the input source 0544 */ 0545 virtual XMLFilePos getSrcOffset() const; 0546 0547 //@} 0548 0549 // ----------------------------------------------------------------------- 0550 // Setter Methods 0551 // ----------------------------------------------------------------------- 0552 /** @name Setter Methods (Xerces-C specific) */ 0553 //@{ 0554 /** 0555 * This method is used to set a validator. 0556 * 0557 * <b>SAX2XMLReader assumes responsibility for the validator. It will be 0558 * deleted when the XMLReader is destroyed.</b> 0559 * 0560 * @param valueToAdopt A pointer to the validator that the reader should use. 0561 * 0562 */ 0563 virtual void setValidator(XMLValidator* valueToAdopt) ; 0564 0565 /** 0566 * This method allows users to set the parser's behaviour when it 0567 * encounters the first fatal error. If set to true, the parser 0568 * will exit at the first fatal error. If false, then it will 0569 * report the error and continue processing. 0570 * 0571 * <p>The default value is 'true' and the parser exits on the 0572 * first fatal error.</p> 0573 * 0574 * <p>Or you can set the feature "http://apache.org/xml/features/continue-after-fatal-error" 0575 * which has the opposite behaviour.</p> 0576 * 0577 * <p>If both the feature above and this function are used, the latter takes effect.</p> 0578 * 0579 * @param newState The value specifying whether the parser should 0580 * continue or exit when it encounters the first 0581 * fatal error. 0582 * 0583 * @see #getExitOnFirstFatalError 0584 * @see #setFeature 0585 */ 0586 virtual void setExitOnFirstFatalError(const bool newState) ; 0587 0588 /** 0589 * This method allows users to set the parser's behaviour when it 0590 * encounters a validation constraint error. If set to true, and the 0591 * the parser will treat validation error as fatal and will exit depends on the 0592 * state of "getExitOnFirstFatalError". If false, then it will 0593 * report the error and continue processing. 0594 * 0595 * Note: setting this true does not mean the validation error will be printed with 0596 * the word "Fatal Error". It is still printed as "Error", but the parser 0597 * will exit if "setExitOnFirstFatalError" is set to true. 0598 * 0599 * <p>The default value is 'false'.</p> 0600 * 0601 * <p>Or you can set the feature "http://apache.org/xml/features/validation-error-as-fatal" 0602 * which means the same thing.</p> 0603 * 0604 * <p>If both the feature above and this function are used, the latter takes effect.</p> 0605 * 0606 * @param newState If true, the parser will exit if "setExitOnFirstFatalError" 0607 * is set to true. 0608 * 0609 * @see #getValidationConstraintFatal 0610 * @see #setExitOnFirstFatalError 0611 * @see #setFeature 0612 */ 0613 virtual void setValidationConstraintFatal(const bool newState) ; 0614 //@} 0615 0616 0617 // ----------------------------------------------------------------------- 0618 // Progressive scan methods 0619 // ----------------------------------------------------------------------- 0620 0621 /** @name Progressive scan methods */ 0622 //@{ 0623 0624 /** Begin a progressive parse operation 0625 * 0626 * This method is used to start a progressive parse on a XML file. 0627 * To continue parsing, subsequent calls must be to the parseNext 0628 * method. 0629 * 0630 * It scans through the prolog and returns a token to be used on 0631 * subsequent scanNext() calls. If the return value is true, then the 0632 * token is legal and ready for further use. If it returns false, then 0633 * the scan of the prolog failed and the token is not going to work on 0634 * subsequent scanNext() calls. 0635 * 0636 * @param systemId A pointer to a Unicode string representing the path 0637 * to the XML file to be parsed. 0638 * @param toFill A token maintaing state information to maintain 0639 * internal consistency between invocation of 'parseNext' 0640 * calls. 0641 * 0642 * @return 'true', if successful in parsing the prolog. It indicates the 0643 * user can go ahead with parsing the rest of the file. It 0644 * returns 'false' to indicate that the parser could parse the 0645 * prolog (which means the token will not be valid.) 0646 * 0647 * @see #parseNext 0648 * @see #parseFirst(char*,...) 0649 * @see #parseFirst(InputSource&,...) 0650 */ 0651 virtual bool parseFirst 0652 ( 0653 const XMLCh* const systemId 0654 , XMLPScanToken& toFill 0655 ) ; 0656 0657 /** Begin a progressive parse operation 0658 * 0659 * This method is used to start a progressive parse on a XML file. 0660 * To continue parsing, subsequent calls must be to the parseNext 0661 * method. 0662 * 0663 * It scans through the prolog and returns a token to be used on 0664 * subsequent scanNext() calls. If the return value is true, then the 0665 * token is legal and ready for further use. If it returns false, then 0666 * the scan of the prolog failed and the token is not going to work on 0667 * subsequent scanNext() calls. 0668 * 0669 * @param systemId A pointer to a regular native string representing 0670 * the path to the XML file to be parsed. 0671 * @param toFill A token maintaing state information to maintain 0672 * internal consistency between invocation of 'parseNext' 0673 * calls. 0674 * 0675 * @return 'true', if successful in parsing the prolog. It indicates the 0676 * user can go ahead with parsing the rest of the file. It 0677 * returns 'false' to indicate that the parser could not parse 0678 * the prolog. 0679 * 0680 * @see #parseNext 0681 * @see #parseFirst(XMLCh*,...) 0682 * @see #parseFirst(InputSource&,...) 0683 */ 0684 virtual bool parseFirst 0685 ( 0686 const char* const systemId 0687 , XMLPScanToken& toFill 0688 ) ; 0689 0690 /** Begin a progressive parse operation 0691 * 0692 * This method is used to start a progressive parse on a XML file. 0693 * To continue parsing, subsequent calls must be to the parseNext 0694 * method. 0695 * 0696 * It scans through the prolog and returns a token to be used on 0697 * subsequent scanNext() calls. If the return value is true, then the 0698 * token is legal and ready for further use. If it returns false, then 0699 * the scan of the prolog failed and the token is not going to work on 0700 * subsequent scanNext() calls. 0701 * 0702 * @param source A const reference to the InputSource object which 0703 * points to the XML file to be parsed. 0704 * @param toFill A token maintaing state information to maintain 0705 * internal consistency between invocation of 'parseNext' 0706 * calls. 0707 * 0708 * @return 'true', if successful in parsing the prolog. It indicates the 0709 * user can go ahead with parsing the rest of the file. It 0710 * returns 'false' to indicate that the parser could not parse 0711 * the prolog. 0712 * 0713 * @see #parseNext 0714 * @see #parseFirst(XMLCh*,...) 0715 * @see #parseFirst(char*,...) 0716 */ 0717 virtual bool parseFirst 0718 ( 0719 const InputSource& source 0720 , XMLPScanToken& toFill 0721 ) ; 0722 0723 /** Continue a progressive parse operation 0724 * 0725 * This method is used to continue with progressive parsing of 0726 * XML files started by a call to 'parseFirst' method. 0727 * 0728 * It parses the XML file and stops as soon as it comes across 0729 * a XML token (as defined in the XML specification). Relevant 0730 * callback handlers are invoked as required by the SAX 0731 * specification. 0732 * 0733 * @param token A token maintaing state information to maintain 0734 * internal consistency between invocation of 'parseNext' 0735 * calls. 0736 * 0737 * @return 'true', if successful in parsing the next XML token. 0738 * It indicates the user can go ahead with parsing the rest 0739 * of the file. It returns 'false' to indicate that the parser 0740 * could not find next token as per the XML specification 0741 * production rule. 0742 * 0743 * @see #parseFirst(XMLCh*,...) 0744 * @see #parseFirst(char*,...) 0745 * @see #parseFirst(InputSource&,...) 0746 */ 0747 virtual bool parseNext(XMLPScanToken& token) ; 0748 0749 /** Reset the parser after a progressive parse 0750 * 0751 * If a progressive parse loop exits before the end of the document 0752 * is reached, the parser has no way of knowing this. So it will leave 0753 * open any files or sockets or memory buffers that were in use at 0754 * the time that the parse loop exited. 0755 * 0756 * The next parse operation will cause these open files and such to 0757 * be closed, but the next parse operation might occur at some unknown 0758 * future point. To avoid this problem, you should reset the parser if 0759 * you exit the loop early. 0760 * 0761 * If you exited because of an error, then this cleanup will be done 0762 * for you. Its only when you exit the file prematurely of your own 0763 * accord, because you've found what you wanted in the file most 0764 * likely. 0765 * 0766 * @param token A token maintaing state information to maintain 0767 * internal consistency between invocation of 'parseNext' 0768 * calls. 0769 */ 0770 virtual void parseReset(XMLPScanToken& token) ; 0771 0772 //@} 0773 0774 // ----------------------------------------------------------------------- 0775 // Implementation of the grammar preparsing interface 0776 // ----------------------------------------------------------------------- 0777 0778 /** @name Implementation of Grammar preparsing interface's. */ 0779 //@{ 0780 /** 0781 * Preparse schema grammar (XML Schema, DTD, etc.) via an input source 0782 * object. 0783 * 0784 * This method invokes the preparsing process on a schema grammar XML 0785 * file specified by the SAX InputSource parameter. 0786 * 0787 * 0788 * @param source A const reference to the SAX InputSource object which 0789 * points to the schema grammar file to be preparsed. 0790 * @param grammarType The grammar type (Schema or DTD). 0791 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0792 * otherwise, no caching. Default is <code>false</code>. 0793 * @return The preparsed schema grammar object (SchemaGrammar or 0794 * DTDGrammar). That grammar object is owned by the parser. 0795 * 0796 * @exception SAXException Any SAX exception, possibly 0797 * wrapping another exception. 0798 * @exception XMLException An exception from the parser or client 0799 * handler code. 0800 * @exception DOMException A DOM exception as per DOM spec. 0801 * 0802 * @see InputSource#InputSource 0803 */ 0804 virtual Grammar* loadGrammar(const InputSource& source, 0805 const Grammar::GrammarType grammarType, 0806 const bool toCache = false); 0807 0808 /** 0809 * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL 0810 * 0811 * This method invokes the preparsing process on a schema grammar XML 0812 * file specified by the file path parameter. 0813 * 0814 * 0815 * @param systemId A const XMLCh pointer to the Unicode string which 0816 * contains the path to the XML grammar file to be 0817 * preparsed. 0818 * @param grammarType The grammar type (Schema or DTD). 0819 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0820 * otherwise, no caching. Default is <code>false</code>. 0821 * @return The preparsed schema grammar object (SchemaGrammar or 0822 * DTDGrammar). That grammar object is owned by the parser. 0823 * 0824 * @exception SAXException Any SAX exception, possibly 0825 * wrapping another exception. 0826 * @exception XMLException An exception from the parser or client 0827 * handler code. 0828 * @exception DOMException A DOM exception as per DOM spec. 0829 */ 0830 virtual Grammar* loadGrammar(const XMLCh* const systemId, 0831 const Grammar::GrammarType grammarType, 0832 const bool toCache = false); 0833 0834 /** 0835 * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL 0836 * 0837 * This method invokes the preparsing process on a schema grammar XML 0838 * file specified by the file path parameter. 0839 * 0840 * 0841 * @param systemId A const char pointer to a native string which contains 0842 * the path to the XML grammar file to be preparsed. 0843 * @param grammarType The grammar type (Schema or DTD). 0844 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0845 * otherwise, no caching. Default is <code>false</code>. 0846 * @return The preparsed schema grammar object (SchemaGrammar or 0847 * DTDGrammar). That grammar object is owned by the parser. 0848 * 0849 * @exception SAXException Any SAX exception, possibly 0850 * wrapping another exception. 0851 * @exception XMLException An exception from the parser or client 0852 * handler code. 0853 * @exception DOMException A DOM exception as per DOM spec. 0854 */ 0855 virtual Grammar* loadGrammar(const char* const systemId, 0856 const Grammar::GrammarType grammarType, 0857 const bool toCache = false); 0858 0859 /** 0860 * Clear the cached grammar pool 0861 */ 0862 virtual void resetCachedGrammarPool(); 0863 0864 /** Set maximum input buffer size 0865 * 0866 * This method allows users to limit the size of buffers used in parsing 0867 * XML character data. The effect of setting this size is to limit the 0868 * size of a ContentHandler::characters() call. 0869 * 0870 * The parser's default input buffer size is 1 megabyte. 0871 * 0872 * @param bufferSize The maximum input buffer size 0873 */ 0874 virtual void setInputBufferSize(const XMLSize_t bufferSize); 0875 0876 //@} 0877 0878 0879 // ----------------------------------------------------------------------- 0880 // Advanced document handler list maintenance methods 0881 // ----------------------------------------------------------------------- 0882 0883 /** @name Advanced document handler list maintenance methods */ 0884 //@{ 0885 /** 0886 * This method installs the specified 'advanced' document callback 0887 * handler, thereby allowing the user to customize the processing, 0888 * if they choose to do so. Any number of advanced callback handlers 0889 * maybe installed. 0890 * 0891 * <p>The methods in the advanced callback interface represent 0892 * Xerces-C extensions. There is no specification for this interface.</p> 0893 * 0894 * @param toInstall A pointer to the users advanced callback handler. 0895 * 0896 * @see #removeAdvDocHandler 0897 */ 0898 virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) ; 0899 0900 /** 0901 * This method removes the 'advanced' document handler callback from 0902 * the underlying parser scanner. If no handler is installed, advanced 0903 * callbacks are not invoked by the scanner. 0904 * @param toRemove A pointer to the advanced callback handler which 0905 * should be removed. 0906 * 0907 * @see #installAdvDocHandler 0908 */ 0909 virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) ; 0910 //@} 0911 0912 // ----------------------------------------------------------------------- 0913 // Implementation of the XMLDocumentHandler interface 0914 // ----------------------------------------------------------------------- 0915 /** @name Implementation of the XMLDocumentHandler Interface. */ 0916 //@{ 0917 /** 0918 * This method is used to report all the characters scanned 0919 * by the parser. The driver will invoke the 'characters' 0920 * method of the user installed SAX Document Handler. 0921 * 0922 * <p>If any advanced callback handlers are installed, the 0923 * corresponding 'docCharacters' method will also be invoked.</p> 0924 * 0925 * @param chars A const pointer to a Unicode string representing the 0926 * character data. 0927 * @param length The length of the Unicode string returned in 'chars'. 0928 * @param cdataSection A flag indicating if the characters represent 0929 * content from the CDATA section. 0930 * @see DocumentHandler#characters 0931 */ 0932 virtual void docCharacters 0933 ( 0934 const XMLCh* const chars 0935 , const XMLSize_t length 0936 , const bool cdataSection 0937 ); 0938 0939 /** 0940 * This method is used to report any comments scanned by the parser. 0941 * This method is a no-op unless, unless an advanced callback handler 0942 * is installed, in which case the corresponding 'docComment' method 0943 * is invoked. 0944 * 0945 * @param comment A const pointer to a null terminated Unicode 0946 * string representing the comment text. 0947 */ 0948 virtual void docComment 0949 ( 0950 const XMLCh* const comment 0951 ); 0952 0953 /** 0954 * This method is used to report any PI scanned by the parser. 0955 * 0956 * <p>Any PI's occurring before any 'content' are not reported 0957 * to any SAX handler as per the specification. However, all 0958 * PI's within content are reported via the SAX Document Handler's 0959 * 'processingInstruction' method. 0960 * 0961 * <p>If any advanced callback handlers are installed, the 0962 * corresponding 'docPI' method will be invoked.</p> 0963 * 0964 * @param target A const pointer to a Unicode string representing the 0965 * target of the PI declaration. 0966 * @param data A const pointer to a Unicode string representing the 0967 * data of the PI declaration. See the PI production rule 0968 * in the XML specification for details. 0969 * 0970 * @see DocumentHandler#processingInstruction 0971 */ 0972 virtual void docPI 0973 ( 0974 const XMLCh* const target 0975 , const XMLCh* const data 0976 ); 0977 0978 /** 0979 * This method is used to indicate the end of root element 0980 * was just scanned by the parser. Corresponding 'endDocument' 0981 * method of the user installed SAX Document Handler will also 0982 * be invoked. 0983 * 0984 * <p>In addition, if any advanced callback handlers are installed, 0985 * the corresponding 'endDocument' method is invoked.</p> 0986 * 0987 * @see DocumentHandler#endDocument 0988 */ 0989 virtual void endDocument(); 0990 0991 /** 0992 * This method is used to indicate the end tag of an element. 0993 * The driver will invoke the corresponding 'endElement' method of 0994 * the SAX Document Handler interface. 0995 * 0996 * <p>If any advanced callback handlers are installed, the 0997 * corresponding 'endElement' method is also invoked.</p> 0998 * 0999 * @param elemDecl A const reference to the object containing element 1000 * declaration information. 1001 * @param urlId An id referring to the namespace prefix, if 1002 * namespaces setting is switched on. 1003 * @param isRoot A flag indicating whether this element was the 1004 * root element. 1005 * @param elemPrefix A const pointer to a Unicode string containing 1006 * the namespace prefix for this element. Applicable 1007 * only when namespace processing is enabled. 1008 * @see DocumentHandler#endElement 1009 */ 1010 virtual void endElement 1011 ( 1012 const XMLElementDecl& elemDecl 1013 , const unsigned int urlId 1014 , const bool isRoot 1015 , const XMLCh* const elemPrefix=0 1016 ); 1017 1018 /** 1019 * This method is used to indicate that an end of an entity reference 1020 * was just scanned. 1021 * 1022 * <p>If any advanced callback handlers are installed, the 1023 * corresponding 'endEntityReference' method is invoked.</p> 1024 * 1025 * @param entDecl A const reference to the object containing the 1026 * entity declaration information. 1027 */ 1028 virtual void endEntityReference 1029 ( 1030 const XMLEntityDecl& entDecl 1031 ); 1032 1033 /** 1034 * This method is used to report all the whitespace characters, 1035 * which are determined to be 'ignorable'. This distinction 1036 * between characters is only made, if validation is enabled. 1037 * Corresponding 'ignorableWhitespace' method of the user installed 1038 * SAX Document Handler interface is called. 1039 * 1040 * <p>Any whitespace before content is not reported to the SAX 1041 * Document Handler method, as per the SAX specification. 1042 * However, if any advanced callback handlers are installed, the 1043 * corresponding 'ignorableWhitespace' method is invoked.</p> 1044 * 1045 * @param chars A const pointer to a Unicode string representing the 1046 * ignorable whitespace character data. 1047 * @param length The length of the Unicode string 'chars'. 1048 * @param cdataSection A flag indicating if the characters represent 1049 * content from the CDATA section. 1050 * @see DocumentHandler#ignorableWhitespace 1051 */ 1052 virtual void ignorableWhitespace 1053 ( 1054 const XMLCh* const chars 1055 , const XMLSize_t length 1056 , const bool cdataSection 1057 ); 1058 1059 /** 1060 * This method allows the user installed Document Handler and 1061 * any advanced callback handlers to 'reset' themselves. 1062 */ 1063 virtual void resetDocument(); 1064 1065 /** 1066 * This method is used to report the start of the parsing process. 1067 * The corresponding user installed SAX Document Handler's method 1068 * 'startDocument' is invoked. 1069 * 1070 * <p>If any advanced callback handlers are installed, then the 1071 * corresponding 'startDocument' method is also called.</p> 1072 * 1073 * @see DocumentHandler#startDocument 1074 */ 1075 virtual void startDocument(); 1076 1077 /** 1078 * This method is used to report the start of an element. It is 1079 * called at the end of the element, by which time all attributes 1080 * specified are also parsed. The corresponding user installed 1081 * SAX Document Handler's method 'startElement' is invoked. 1082 * 1083 * <p>If any advanced callback handlers are installed, then the 1084 * corresponding 'startElement' method is also called.</p> 1085 * 1086 * @param elemDecl A const reference to the object containing element 1087 * declaration information. 1088 * @param urlId An id referring to the namespace prefix, if 1089 * namespaces setting is switched on. 1090 * @param elemPrefix A const pointer to a Unicode string containing 1091 * the namespace prefix for this element. Applicable 1092 * only when namespace processing is enabled. 1093 * @param attrList A const reference to the object containing the 1094 * list of attributes just scanned for this element. 1095 * @param attrCount A count of number of attributes in the list 1096 * specified by the parameter 'attrList'. 1097 * @param isEmpty A flag indicating whether this is an empty element 1098 * or not. 1099 * @param isRoot A flag indicating whether this element was the 1100 * root element. 1101 * @see DocumentHandler#startElement 1102 */ 1103 virtual void startElement 1104 ( 1105 const XMLElementDecl& elemDecl 1106 , const unsigned int urlId 1107 , const XMLCh* const elemPrefix 1108 , const RefVectorOf<XMLAttr>& attrList 1109 , const XMLSize_t attrCount 1110 , const bool isEmpty 1111 , const bool isRoot 1112 ); 1113 1114 /** 1115 * This method is used to indicate the start of an entity reference. 1116 * 1117 * <p>If any advanced callback handlers are installed, the 1118 * corresponding 'endEntityReference' method is invoked.</p> 1119 * 1120 * @param entDecl A const reference to the object containing the 1121 * entity declaration information. 1122 */ 1123 virtual void startEntityReference 1124 ( 1125 const XMLEntityDecl& entDecl 1126 ); 1127 1128 /** 1129 * This method is used to report the XML decl scanned by the parser. 1130 * Refer to the XML specification to see the meaning of parameters. 1131 * 1132 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1133 * implementation.</font></b> 1134 * 1135 * @param versionStr A const pointer to a Unicode string representing 1136 * version string value. 1137 * @param encodingStr A const pointer to a Unicode string representing 1138 * the encoding string value. 1139 * @param standaloneStr A const pointer to a Unicode string 1140 * representing the standalone string value. 1141 * @param actualEncodingStr A const pointer to a Unicode string 1142 * representing the actual encoding string 1143 * value. 1144 */ 1145 virtual void XMLDecl 1146 ( 1147 const XMLCh* const versionStr 1148 , const XMLCh* const encodingStr 1149 , const XMLCh* const standaloneStr 1150 , const XMLCh* const actualEncodingStr 1151 ); 1152 //@} 1153 1154 1155 // ----------------------------------------------------------------------- 1156 // Implementation of the XMLErrorReporter interface 1157 // ----------------------------------------------------------------------- 1158 1159 /** @name Implementation of the XMLErrorReporter Interface. */ 1160 //@{ 1161 /** 1162 * This method is used to report back errors found while parsing the 1163 * XML file. The driver will call the corresponding user installed 1164 * SAX Error Handler methods: 'fatal', 'error', 'warning' depending 1165 * on the severity of the error. This classification is defined by 1166 * the XML specification. 1167 * 1168 * @param errCode An integer code for the error. 1169 * @param msgDomain A const pointer to an Unicode string representing 1170 * the message domain to use. 1171 * @param errType An enumeration classifying the severity of the error. 1172 * @param errorText A const pointer to an Unicode string representing 1173 * the text of the error message. 1174 * @param systemId A const pointer to an Unicode string representing 1175 * the system id of the XML file where this error 1176 * was discovered. 1177 * @param publicId A const pointer to an Unicode string representing 1178 * the public id of the XML file where this error 1179 * was discovered. 1180 * @param lineNum The line number where the error occurred. 1181 * @param colNum The column number where the error occurred. 1182 * @see ErrorHandler 1183 */ 1184 virtual void error 1185 ( 1186 const unsigned int errCode 1187 , const XMLCh* const msgDomain 1188 , const XMLErrorReporter::ErrTypes errType 1189 , const XMLCh* const errorText 1190 , const XMLCh* const systemId 1191 , const XMLCh* const publicId 1192 , const XMLFileLoc lineNum 1193 , const XMLFileLoc colNum 1194 ); 1195 1196 /** 1197 * This method allows the user installed Error Handler 1198 * callback to 'reset' itself. 1199 * 1200 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1201 * implementation.</font></b> 1202 * 1203 */ 1204 virtual void resetErrors(); 1205 //@} 1206 1207 1208 // ----------------------------------------------------------------------- 1209 // Implementation of the XMLEntityHandler interface 1210 // ----------------------------------------------------------------------- 1211 1212 /** @name Implementation of the XMLEntityHandler Interface. */ 1213 //@{ 1214 /** 1215 * This method is used to indicate the end of parsing of an external 1216 * entity file. 1217 * 1218 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1219 * implementation.</font></b> 1220 * 1221 * @param inputSource A const reference to the InputSource object 1222 * which points to the XML file being parsed. 1223 * @see InputSource 1224 */ 1225 virtual void endInputSource(const InputSource& inputSource); 1226 1227 /** 1228 * This method allows an installed XMLEntityHandler to further 1229 * process any system id's of external entities encountered in 1230 * the XML file being parsed, such as redirection etc. 1231 * 1232 * <b><font color="#FF0000">This method always returns 'false' 1233 * for this SAX driver implementation.</font></b> 1234 * 1235 * @param systemId A const pointer to an Unicode string representing 1236 * the system id scanned by the parser. 1237 * @param toFill A pointer to a buffer in which the application 1238 * processed system id is stored. 1239 * @return 'true', if any processing is done, 'false' otherwise. 1240 */ 1241 virtual bool expandSystemId 1242 ( 1243 const XMLCh* const systemId 1244 , XMLBuffer& toFill 1245 ); 1246 1247 /** 1248 * This method allows the installed XMLEntityHandler to reset 1249 * itself. 1250 * 1251 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1252 * implementation.</font></b> 1253 */ 1254 virtual void resetEntities(); 1255 1256 /** Resolve a public/system id 1257 * 1258 * This method allows a user installed entity handler to further 1259 * process any pointers to external entities. The applications can 1260 * implement 'redirection' via this callback. 1261 * 1262 * @param resourceIdentifier An object containing the type of 1263 * resource to be resolved and the associated data members 1264 * corresponding to this type. 1265 * @return The value returned by the user installed resolveEntity 1266 * method or NULL otherwise to indicate no processing was done. 1267 * The returned InputSource is owned by the parser which is 1268 * responsible to clean up the memory. 1269 * @see XMLEntityHandler 1270 * @see XMLEntityResolver 1271 */ 1272 virtual InputSource* resolveEntity 1273 ( 1274 XMLResourceIdentifier* resourceIdentifier 1275 ); 1276 1277 /** 1278 * This method is used to indicate the start of parsing an 1279 * external entity file. 1280 * 1281 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1282 * implementation.</font></b> 1283 * 1284 * @param inputSource A const reference to the InputSource object 1285 * which points to the external entity 1286 * being parsed. 1287 */ 1288 virtual void startInputSource(const InputSource& inputSource); 1289 //@} 1290 1291 // ----------------------------------------------------------------------- 1292 // Implementation of the Deprecated DocTypeHandler Interface 1293 // ----------------------------------------------------------------------- 1294 1295 /** @name Implementation of the deprecated DocTypeHandler Interface */ 1296 //@{ 1297 /** 1298 * This method is used to report an attribute definition. 1299 * 1300 * <b><font color="#FF0000">This method is a no-op for this SAX 1301 * driver implementation.</font></b> 1302 * 1303 * @param elemDecl A const reference to the object containing information 1304 * about the element whose attribute definition was just 1305 * parsed. 1306 * @param attDef A const reference to the object containing information 1307 * attribute definition. 1308 * @param ignore The flag indicating whether this attribute definition 1309 * was ignored by the parser or not. 1310 */ 1311 virtual void attDef 1312 ( 1313 const DTDElementDecl& elemDecl 1314 , const DTDAttDef& attDef 1315 , const bool ignoring 1316 ); 1317 1318 /** 1319 * This method is used to report a comment occurring within the DTD. 1320 * 1321 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1322 * implementation.</font></b> 1323 * 1324 * @param comment A const pointer to a Unicode string representing the 1325 * text of the comment just parsed. 1326 */ 1327 virtual void doctypeComment 1328 ( 1329 const XMLCh* const comment 1330 ); 1331 1332 /** 1333 * This method is used to report the DOCTYPE declaration. 1334 * 1335 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1336 * implementation.</font></b> 1337 * 1338 * @param elemDecl A const reference to the object containing information 1339 * about the root element definition declaration of the 1340 * XML document being parsed. 1341 * @param publicId A const pointer to a Unicode string representing the 1342 * public id of the DTD file. 1343 * @param systemId A const pointer to a Unicode string representing the 1344 * system id of the DTD file. 1345 * @param hasIntSubset A flag indicating if this XML file contains any 1346 * internal subset. 1347 * @param hasExtSubset A flag indicating if this XML file contains any 1348 * external subset. Default is false. 1349 */ 1350 virtual void doctypeDecl 1351 ( 1352 const DTDElementDecl& elemDecl 1353 , const XMLCh* const publicId 1354 , const XMLCh* const systemId 1355 , const bool hasIntSubset 1356 , const bool hasExtSubset = false 1357 ); 1358 1359 /** 1360 * This method is used to report any PI declarations 1361 * occurring inside the DTD definition block. 1362 * 1363 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1364 * implementation.</font></b> 1365 * 1366 * @param target A const pointer to a Unicode string representing the 1367 * target of the PI declaration. 1368 * @param data A const pointer to a Unicode string representing the 1369 * data of the PI declaration. See the PI production rule 1370 * in the XML specification for details. 1371 */ 1372 virtual void doctypePI 1373 ( 1374 const XMLCh* const target 1375 , const XMLCh* const data 1376 ); 1377 1378 /** 1379 * This method is used to report any whitespaces 1380 * occurring inside the DTD definition block. 1381 * 1382 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1383 * implementation.</font></b> 1384 * 1385 * @param chars A const pointer to a Unicode string representing the 1386 * whitespace characters. 1387 * @param length The length of the whitespace Unicode string. 1388 */ 1389 virtual void doctypeWhitespace 1390 ( 1391 const XMLCh* const chars 1392 , const XMLSize_t length 1393 ); 1394 1395 /** 1396 * This method is used to report an element declarations 1397 * successfully scanned by the parser. 1398 * 1399 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1400 * implementation.</font></b> 1401 * 1402 * @param decl A const reference to the object containing element 1403 * declaration information. 1404 * @param isIgnored The flag indicating whether this definition was 1405 * ignored by the parser or not. 1406 */ 1407 virtual void elementDecl 1408 ( 1409 const DTDElementDecl& decl 1410 , const bool isIgnored 1411 ); 1412 1413 /** 1414 * This method is used to report the end of an attribute 1415 * list declaration for an element. 1416 * 1417 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1418 * implementation.</font></b> 1419 * 1420 * @param elemDecl A const reference to the object containing element 1421 * declaration information. 1422 */ 1423 virtual void endAttList 1424 ( 1425 const DTDElementDecl& elemDecl 1426 ); 1427 1428 /** 1429 * This method is used to report the end of the internal subset. 1430 * 1431 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1432 * implementation.</font></b> 1433 */ 1434 virtual void endIntSubset(); 1435 1436 /** 1437 * This method is used to report the end of the external subset. 1438 * 1439 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1440 * implementation.</font></b> 1441 */ 1442 virtual void endExtSubset(); 1443 1444 /** 1445 * This method is used to report any entity declarations. 1446 * For unparsed entities, this driver will invoke the 1447 * SAX DTDHandler::unparsedEntityDecl callback. 1448 * 1449 * @param entityDecl A const reference to the object containing 1450 * the entity declaration information. 1451 * @param isPEDecl The flag indicating whether this was a 1452 * parameter entity declaration or not. 1453 * @param isIgnored The flag indicating whether this definition 1454 * was ignored by the parser or not. 1455 * 1456 * @see DTDHandler#unparsedEntityDecl 1457 */ 1458 virtual void entityDecl 1459 ( 1460 const DTDEntityDecl& entityDecl 1461 , const bool isPEDecl 1462 , const bool isIgnored 1463 ); 1464 1465 /** 1466 * This method allows the user installed DTD handler to 1467 * reset itself. 1468 */ 1469 virtual void resetDocType(); 1470 1471 /** 1472 * This method is used to report any notation declarations. 1473 * If there is a user installed DTDHandler, then the driver will 1474 * invoke the SAX DTDHandler::notationDecl callback. 1475 * 1476 * @param notDecl A const reference to the object containing the notation 1477 * declaration information. 1478 * @param isIgnored The flag indicating whether this definition was ignored 1479 * by the parser or not. 1480 * 1481 * @see DTDHandler#notationDecl 1482 */ 1483 virtual void notationDecl 1484 ( 1485 const XMLNotationDecl& notDecl 1486 , const bool isIgnored 1487 ); 1488 1489 /** 1490 * This method is used to indicate the start of an element's attribute 1491 * list declaration. 1492 * 1493 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1494 * implementation.</font></b> 1495 * 1496 * @param elemDecl A const reference to the object containing element 1497 * declaration information. 1498 */ 1499 virtual void startAttList 1500 ( 1501 const DTDElementDecl& elemDecl 1502 ); 1503 1504 /** 1505 * This method is used indicate the start of the internal subset. 1506 * 1507 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1508 * implementation.</font></b> 1509 */ 1510 virtual void startIntSubset(); 1511 1512 /** 1513 * This method is used indicate the start of the external subset. 1514 * 1515 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1516 * implementation.</font></b> 1517 */ 1518 virtual void startExtSubset(); 1519 1520 /** 1521 * This method is used to report the TextDecl. Refer to the XML 1522 * specification for the syntax of a TextDecl. 1523 * 1524 * <b><font color="#FF0000">This method is a no-op for this SAX driver 1525 * implementation.</font></b> 1526 * 1527 * @param versionStr A const pointer to a Unicode string representing 1528 * the version number of the 'version' clause. 1529 * @param encodingStr A const pointer to a Unicode string representing 1530 * the encoding name of the 'encoding' clause. 1531 */ 1532 virtual void TextDecl 1533 ( 1534 const XMLCh* const versionStr 1535 , const XMLCh* const encodingStr 1536 ); 1537 //@} 1538 1539 1540 private : 1541 // ----------------------------------------------------------------------- 1542 // Unimplemented constructors and operators 1543 // ----------------------------------------------------------------------- 1544 SAX2XMLReaderImpl(const SAX2XMLReaderImpl&); 1545 SAX2XMLReaderImpl& operator=(const SAX2XMLReaderImpl&); 1546 1547 // ----------------------------------------------------------------------- 1548 // Initialize/Cleanup methods 1549 // ----------------------------------------------------------------------- 1550 void initialize(); 1551 void cleanUp(); 1552 void resetInProgress(); 1553 1554 // ----------------------------------------------------------------------- 1555 // Private data members 1556 // 1557 // fAttrList 1558 // A temporary implementation of the basic SAX2 Attributes 1559 // interface. We use this one over and over on each startElement 1560 // event to allow SAX-like access to the element attributes. 1561 // 1562 // fDocHandler 1563 // The installed SAX content handler, if any. Null if none. 1564 // 1565 // fnamespacePrefix 1566 // Indicates whether the namespace-prefix feature is on or off. 1567 // 1568 // fautoValidation 1569 // Indicates whether automatic validation is on or off 1570 // 1571 // fValidation 1572 // Indicates whether the 'validation' core features is on or off 1573 // 1574 // fReuseGrammar 1575 // Tells the parser whether it should reuse the grammar or not. 1576 // If true, there cannot be any internal subset. 1577 // 1578 // fPrefixesStorage 1579 // the namespace prefixes will be allocated from this pool 1580 // 1581 // fPrefixes 1582 // A Stack of the current namespace prefixes that need calls to 1583 // endPrefixMapping 1584 // 1585 // fPrefixCounts 1586 // A Stack of the number of prefixes that need endPrefixMapping 1587 // calls for that element 1588 // 1589 // fDTDHandler 1590 // The installed SAX DTD handler, if any. Null if none. 1591 // 1592 // fElemDepth 1593 // This is used to track the element nesting depth, so that we can 1594 // know when we are inside content. This is so we can ignore char 1595 // data outside of content. 1596 // 1597 // fEntityResolver 1598 // The installed SAX entity handler, if any. Null if none. 1599 // 1600 // fErrorHandler 1601 // The installed SAX error handler, if any. Null if none. 1602 // 1603 // fLexicalHandler 1604 // The installed SAX lexical handler, if any. Null if none. 1605 // 1606 // fDecllHandler 1607 // The installed SAX declaration handler, if any. Null if none. 1608 // 1609 // fAdvDHCount 1610 // fAdvDHList 1611 // fAdvDHListSize 1612 // This is an array of pointers to XMLDocumentHandlers, which is 1613 // how we see installed advanced document handlers. There will 1614 // usually not be very many at all, so a simple array is used 1615 // instead of a collection, for performance. It will grow if needed, 1616 // but that is unlikely. 1617 // 1618 // The count is how many handlers are currently installed. The size 1619 // is how big the array itself is (for expansion purposes.) When 1620 // count == size, is time to expand. 1621 // 1622 // fParseInProgress 1623 // This flag is set once a parse starts. It is used to prevent 1624 // multiple entrance or reentrance of the parser. 1625 // 1626 // fScanner 1627 // The scanner being used by this parser. It is created internally 1628 // during construction. 1629 // 1630 // fHasExternalSubset 1631 // Indicate if the document has external DTD subset. 1632 // 1633 // fGrammarPool 1634 // The grammar pool passed from external application (through derivatives). 1635 // which could be 0, not owned. 1636 // 1637 // ----------------------------------------------------------------------- 1638 bool fNamespacePrefix; 1639 bool fAutoValidation; 1640 bool fValidation; 1641 bool fParseInProgress; 1642 bool fHasExternalSubset; 1643 XMLSize_t fElemDepth; 1644 XMLSize_t fAdvDHCount; 1645 XMLSize_t fAdvDHListSize; 1646 VecAttributesImpl fAttrList ; 1647 ContentHandler* fDocHandler ; 1648 RefVectorOf<XMLAttr>* fTempAttrVec ; 1649 XMLStringPool* fPrefixesStorage ; 1650 ValueStackOf<unsigned int>* fPrefixes ; 1651 ValueStackOf<XMLSize_t>* fPrefixCounts ; 1652 XMLBuffer* fTempQName; 1653 DTDHandler* fDTDHandler; 1654 EntityResolver* fEntityResolver; 1655 XMLEntityResolver* fXMLEntityResolver; 1656 ErrorHandler* fErrorHandler; 1657 PSVIHandler* fPSVIHandler; 1658 LexicalHandler* fLexicalHandler; 1659 DeclHandler* fDeclHandler; 1660 XMLDocumentHandler** fAdvDHList; 1661 XMLScanner* fScanner; 1662 GrammarResolver* fGrammarResolver; 1663 XMLStringPool* fURIStringPool; 1664 XMLValidator* fValidator; 1665 MemoryManager* fMemoryManager; 1666 XMLGrammarPool* fGrammarPool; 1667 1668 // ----------------------------------------------------------------------- 1669 // internal function used to set the state of the parser 1670 // ----------------------------------------------------------------------- 1671 void setValidationScheme(const ValSchemes newScheme); 1672 void setDoNamespaces(const bool newState); 1673 bool getDoNamespaces() const; 1674 void setDoSchema(const bool newState); 1675 bool getDoSchema() const; 1676 }; 1677 1678 1679 // --------------------------------------------------------------------------- 1680 // SAX2XMLReader: Getter methods 1681 // --------------------------------------------------------------------------- 1682 inline ContentHandler* SAX2XMLReaderImpl::getContentHandler() const 1683 { 1684 return fDocHandler; 1685 } 1686 1687 inline DTDHandler* SAX2XMLReaderImpl::getDTDHandler() const 1688 { 1689 return fDTDHandler ; 1690 } 1691 1692 inline EntityResolver* SAX2XMLReaderImpl::getEntityResolver() const 1693 { 1694 return fEntityResolver; 1695 } 1696 1697 inline XMLEntityResolver* SAX2XMLReaderImpl::getXMLEntityResolver() const 1698 { 1699 return fXMLEntityResolver; 1700 } 1701 1702 inline ErrorHandler* SAX2XMLReaderImpl::getErrorHandler() const 1703 { 1704 return fErrorHandler; 1705 } 1706 1707 inline PSVIHandler* SAX2XMLReaderImpl::getPSVIHandler() const 1708 { 1709 return fPSVIHandler; 1710 } 1711 1712 inline LexicalHandler* SAX2XMLReaderImpl::getLexicalHandler() const 1713 { 1714 return fLexicalHandler; 1715 } 1716 1717 inline DeclHandler* SAX2XMLReaderImpl::getDeclarationHandler() const 1718 { 1719 return fDeclHandler; 1720 } 1721 1722 inline bool SAX2XMLReaderImpl::getExitOnFirstFatalError() const 1723 { 1724 return fScanner->getExitOnFirstFatal(); 1725 } 1726 1727 inline bool SAX2XMLReaderImpl::getValidationConstraintFatal() const 1728 { 1729 return fScanner->getValidationConstraintFatal(); 1730 } 1731 1732 inline Grammar* SAX2XMLReaderImpl::getRootGrammar() 1733 { 1734 return fScanner->getRootGrammar(); 1735 } 1736 1737 inline const XMLCh* SAX2XMLReaderImpl::getURIText(unsigned int uriId) const 1738 { 1739 return fScanner->getURIText(uriId); 1740 } 1741 1742 inline XMLFilePos SAX2XMLReaderImpl::getSrcOffset() const 1743 { 1744 return fScanner->getSrcOffset(); 1745 } 1746 1747 XERCES_CPP_NAMESPACE_END 1748 1749 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |