|
||||
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_SAX2XMLREADER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_SAX2XMLREADER_HPP 0024 0025 #include <xercesc/util/XercesDefs.hpp> 0026 #include <xercesc/util/XMLUniDefs.hpp> 0027 #include <xercesc/framework/XMLValidator.hpp> 0028 #include <xercesc/framework/XMLPScanToken.hpp> 0029 #include <xercesc/validators/common/Grammar.hpp> 0030 0031 XERCES_CPP_NAMESPACE_BEGIN 0032 0033 class ContentHandler ; 0034 class DTDHandler; 0035 class EntityResolver; 0036 class ErrorHandler; 0037 class InputSource; 0038 class LexicalHandler; 0039 class DeclHandler; 0040 class XMLDocumentHandler; 0041 0042 class SAX2_EXPORT SAX2XMLReader 0043 { 0044 public: 0045 // ----------------------------------------------------------------------- 0046 // Class types 0047 // ----------------------------------------------------------------------- 0048 /** @name Public constants */ 0049 //@{ 0050 0051 /** ValScheme enum used in setValidationScheme 0052 * Val_Never: Do not report validation errors. 0053 * Val_Always: The parser will always report validation errors. 0054 * Val_Auto: The parser will report validation errors only if a grammar is specified. 0055 * 0056 * The schemes map to these feature values: 0057 * Val_Never: 0058 * parser->setFeature(XMLUni::fgSAX2CoreValidation, false); 0059 * 0060 * Val_Always: 0061 * parser->setFeature(XMLUni::fgSAX2CoreValidation, true); 0062 * parser->setFeature(XMLUni::fgXercesDynamic, false); 0063 * 0064 * Val_Auto: 0065 * parser->setFeature(XMLUni::fgSAX2CoreValidation, true); 0066 * parser->setFeature(XMLUni::fgXercesDynamic, true); 0067 * 0068 * @see #setFeature 0069 */ 0070 enum ValSchemes 0071 { 0072 Val_Never 0073 , Val_Always 0074 , Val_Auto 0075 }; 0076 //@} 0077 0078 0079 // ----------------------------------------------------------------------- 0080 // Constructors and Destructor 0081 // ----------------------------------------------------------------------- 0082 /** @name Constructors and Destructor */ 0083 //@{ 0084 /** The default constructor */ 0085 SAX2XMLReader() 0086 { 0087 } 0088 /** The destructor */ 0089 virtual ~SAX2XMLReader() 0090 { 0091 } 0092 //@} 0093 0094 //----------------------------------------------------------------------- 0095 // The XMLReader interface 0096 //----------------------------------------------------------------------- 0097 /** @name Implementation of SAX 2.0 XMLReader interface's. */ 0098 //@{ 0099 0100 /** 0101 * This method returns the installed content handler. 0102 * 0103 * @return A pointer to the installed content handler object. 0104 */ 0105 virtual ContentHandler* getContentHandler() const = 0 ; 0106 0107 /** 0108 * This method returns the installed DTD handler. 0109 * 0110 * @return A pointer to the installed DTD handler object. 0111 */ 0112 virtual DTDHandler* getDTDHandler() const = 0; 0113 0114 /** 0115 * This method returns the installed entity resolver. 0116 * 0117 * @return A pointer to the installed entity resolver object. 0118 */ 0119 virtual EntityResolver* getEntityResolver() const = 0 ; 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 = 0 ; 0127 0128 /** 0129 * Query the current state of any feature in a SAX2 XMLReader. 0130 * 0131 * @param name The unique identifier (URI) of the feature being set. 0132 * @return The current state of the feature. 0133 * @exception SAXNotRecognizedException If the requested feature is not known. 0134 */ 0135 virtual bool getFeature(const XMLCh* const name) const = 0; 0136 0137 /** 0138 * Query the current value of a property in a SAX2 XMLReader. 0139 * 0140 * The parser owns the returned pointer. The memory allocated for 0141 * the returned pointer will be destroyed when the parser is deleted. 0142 * 0143 * To ensure accessibility of the returned information after the parser 0144 * is deleted, callers need to copy and store the returned information 0145 * somewhere else; otherwise you may get unexpected result. Since the returned 0146 * pointer is a generic void pointer, see the SAX2 Programming Guide to learn 0147 * exactly what type of property value each property returns for replication. 0148 * 0149 * @param name The unique identifier (URI) of the property being set. 0150 * @return The current value of the property. The pointer spans the same 0151 * life-time as the parser. A null pointer is returned if nothing 0152 * was specified externally. 0153 * @exception SAXNotRecognizedException If the requested property is not known. 0154 */ 0155 virtual void* getProperty(const XMLCh* const name) const = 0 ; 0156 0157 /** 0158 * Allow an application to register a document event handler. 0159 * 0160 * If the application does not register a document handler, all 0161 * document events reported by the SAX parser will be silently 0162 * ignored (this is the default behaviour implemented by 0163 * HandlerBase). 0164 * 0165 * Applications may register a new or different handler in the 0166 * middle of a parse, and the SAX parser must begin using the new 0167 * handler immediately. 0168 * 0169 * @param handler The document handler. 0170 * @see ContentHandler#ContentHandler 0171 * @see HandlerBase#HandlerBase 0172 */ 0173 virtual void setContentHandler(ContentHandler* const handler) = 0; 0174 0175 /** 0176 * Allow an application to register a DTD event handler. 0177 * 0178 * If the application does not register a DTD handler, all DTD 0179 * events reported by the SAX parser will be silently ignored (this 0180 * is the default behaviour implemented by HandlerBase). 0181 * 0182 * Applications may register a new or different handler in the middle 0183 * of a parse, and the SAX parser must begin using the new handler 0184 * immediately. 0185 * 0186 * @param handler The DTD handler. 0187 * @see DTDHandler#DTDHandler 0188 * @see HandlerBase#HandlerBase 0189 */ 0190 virtual void setDTDHandler(DTDHandler* const handler) = 0; 0191 0192 /** 0193 * Allow an application to register a custom entity resolver. 0194 * 0195 * If the application does not register an entity resolver, the 0196 * SAX parser will resolve system identifiers and open connections 0197 * to entities itself (this is the default behaviour implemented in 0198 * DefaultHandler). 0199 * 0200 * Applications may register a new or different entity resolver 0201 * in the middle of a parse, and the SAX parser must begin using 0202 * the new resolver immediately. 0203 * 0204 * @param resolver The object for resolving entities. 0205 * @see EntityResolver#EntityResolver 0206 * @see DefaultHandler#DefaultHandler 0207 */ 0208 virtual void setEntityResolver(EntityResolver* const resolver) = 0; 0209 0210 /** 0211 * Allow an application to register an error event handler. 0212 * 0213 * If the application does not register an error event handler, 0214 * all error events reported by the SAX parser will be silently 0215 * ignored, except for fatalError, which will throw a SAXException 0216 * (this is the default behaviour implemented by HandlerBase). 0217 * 0218 * Applications may register a new or different handler in the 0219 * middle of a parse, and the SAX parser must begin using the new 0220 * handler immediately. 0221 * 0222 * @param handler The error handler. 0223 * @see ErrorHandler#ErrorHandler 0224 * @see SAXException#SAXException 0225 * @see HandlerBase#HandlerBase 0226 */ 0227 virtual void setErrorHandler(ErrorHandler* const handler) = 0; 0228 0229 /** 0230 * Set the state of any feature in a SAX2 XMLReader. 0231 * Supported features in SAX2 for xerces-c are: 0232 * <br>(See the SAX2 Programming Guide for detail description). 0233 * 0234 * <br>http://xml.org/sax/features/validation (default: true) 0235 * <br>http://xml.org/sax/features/namespaces (default: true) 0236 * <br>http://xml.org/sax/features/namespace-prefixes (default: false) 0237 * <br>http://apache.org/xml/features/validation/dynamic (default: false) 0238 * <br>http://apache.org/xml/features/validation/reuse-grammar (default: false) 0239 * <br>http://apache.org/xml/features/validation/schema (default: true) 0240 * <br>http://apache.org/xml/features/validation/schema-full-checking (default: false) 0241 * <br>http://apache.org/xml/features/validating/load-schema (default: true) 0242 * <br>http://apache.org/xml/features/nonvalidating/load-external-dtd (default: true) 0243 * <br>http://apache.org/xml/features/continue-after-fatal-error (default: false) 0244 * <br>http://apache.org/xml/features/validation-error-as-fatal (default: false) 0245 * 0246 * @param name The unique identifier (URI) of the feature. 0247 * @param value The requested state of the feature (true or false). 0248 * @exception SAXNotRecognizedException If the requested feature is not known. 0249 * @exception SAXNotSupportedException Feature modification is not supported during parse 0250 * 0251 */ 0252 virtual void setFeature(const XMLCh* const name, const bool value) = 0; 0253 0254 /** 0255 * Set the value of any property in a SAX2 XMLReader. 0256 * Supported properties in SAX2 for xerces-c are: 0257 * <br>(See the SAX2 Programming Guide for detail description). 0258 * 0259 * <br>http://apache.org/xml/properties/schema/external-schemaLocation 0260 * <br>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation 0261 * <br>http://apache.org/xml/properties/security-manager 0262 * <br>http://apache.org/xml/properties/low-water-mark 0263 * <br>http://apache.org/xml/properties/scannerName 0264 * 0265 * It takes a void pointer as the property value. Application is required to initialize this void 0266 * pointer to a correct type. See the SAX2 Programming Guide 0267 * to learn exactly what type of property value each property expects for processing. 0268 * Passing a void pointer that was initialized with a wrong type will lead to unexpected result. 0269 * If the same property is set more than once, the last one takes effect. 0270 * 0271 * @param name The unique identifier (URI) of the property being set. 0272 * @param value The requested value for the property. See 0273 * the SAX2 Programming Guide to learn 0274 * exactly what type of property value each property expects for processing. 0275 * Passing a void pointer that was initialized with a wrong type will lead 0276 * to unexpected result. 0277 * @exception SAXNotRecognizedException If the requested property is not known. 0278 * @exception SAXNotSupportedException Property modification is not supported during parse 0279 */ 0280 virtual void setProperty(const XMLCh* const name, void* value) = 0 ; 0281 0282 /** 0283 * Parse an XML document. 0284 * 0285 * The application can use this method to instruct the SAX parser 0286 * to begin parsing an XML document from any valid input 0287 * source (a character stream, a byte stream, or a URI). 0288 * 0289 * Applications may not invoke this method while a parse is in 0290 * progress (they should create a new Parser instead for each 0291 * additional XML document). Once a parse is complete, an 0292 * application may reuse the same Parser object, possibly with a 0293 * different input source. 0294 * 0295 * @param source The input source for the top-level of the 0296 * XML document. 0297 * @exception SAXException Any SAX exception, possibly 0298 * wrapping another exception. 0299 * @exception XMLException An exception from the parser or client 0300 * handler code. 0301 * @see InputSource#InputSource 0302 * @see #setEntityResolver 0303 * @see #setDTDHandler 0304 * @see #setContentHandler 0305 * @see #setErrorHandler 0306 */ 0307 virtual void parse 0308 ( 0309 const InputSource& source 0310 ) = 0; 0311 0312 /** 0313 * Parse an XML document from a system identifier (URI). 0314 * 0315 * This method is a shortcut for the common case of reading a 0316 * document from a system identifier. It is the exact equivalent 0317 * of the following: 0318 * 0319 * parse(new URLInputSource(systemId)); 0320 * 0321 * If the system identifier is a URL, it must be fully resolved 0322 * by the application before it is passed to the parser. 0323 * 0324 * @param systemId The system identifier (URI). 0325 * @exception SAXException Any SAX exception, possibly 0326 * wrapping another exception. 0327 * @exception XMLException An exception from the parser or client 0328 * handler code. 0329 * @see #parse(const InputSource&) 0330 */ 0331 virtual void parse 0332 ( 0333 const XMLCh* const systemId 0334 ) = 0; 0335 0336 /** 0337 * Parse an XML document from a system identifier (URI). 0338 * 0339 * This method is a shortcut for the common case of reading a 0340 * document from a system identifier. It is the exact equivalent 0341 * of the following: 0342 * 0343 * parse(new URLInputSource(systemId)); 0344 * 0345 * If the system identifier is a URL, it must be fully resolved 0346 * by the application before it is passed to the parser. 0347 * 0348 * @param systemId The system identifier (URI). 0349 * @exception SAXException Any SAX exception, possibly 0350 * wrapping another exception. 0351 * @exception XMLException An exception from the parser or client 0352 * handler code. 0353 * @see #parse(const InputSource&) 0354 */ 0355 virtual void parse 0356 ( 0357 const char* const systemId 0358 ) = 0; 0359 0360 //@} 0361 0362 // ----------------------------------------------------------------------- 0363 // SAX 2.0-ext 0364 // ----------------------------------------------------------------------- 0365 /** @name SAX 2.0-ext */ 0366 //@{ 0367 /** 0368 * This method returns the installed declaration handler. 0369 * 0370 * @return A pointer to the installed declaration handler object. 0371 */ 0372 virtual DeclHandler* getDeclarationHandler() const = 0 ; 0373 0374 /** 0375 * This method returns the installed lexical handler. 0376 * 0377 * @return A pointer to the installed lexical handler object. 0378 */ 0379 virtual LexicalHandler* getLexicalHandler() const = 0 ; 0380 0381 /** 0382 * Allow an application to register a declaration event handler. 0383 * 0384 * If the application does not register a declaration handler, 0385 * all events reported by the SAX parser will be silently 0386 * ignored. (this is the default behaviour implemented by DefaultHandler). 0387 * 0388 * Applications may register a new or different handler in the 0389 * middle of a parse, and the SAX parser must begin using the new 0390 * handler immediately. 0391 * 0392 * @param handler The DTD declaration handler. 0393 * @see DeclHandler#DeclHandler 0394 * @see SAXException#SAXException 0395 * @see DefaultHandler#DefaultHandler 0396 */ 0397 virtual void setDeclarationHandler(DeclHandler* const handler) = 0; 0398 0399 /** 0400 * Allow an application to register a lexical event handler. 0401 * 0402 * If the application does not register a lexical handler, 0403 * all events reported by the SAX parser will be silently 0404 * ignored. (this is the default behaviour implemented by HandlerBase). 0405 * 0406 * Applications may register a new or different handler in the 0407 * middle of a parse, and the SAX parser must begin using the new 0408 * handler immediately. 0409 * 0410 * @param handler The error handler. 0411 * @see LexicalHandler#LexicalHandler 0412 * @see SAXException#SAXException 0413 * @see HandlerBase#HandlerBase 0414 */ 0415 virtual void setLexicalHandler(LexicalHandler* const handler) = 0; 0416 0417 //@} 0418 0419 // ----------------------------------------------------------------------- 0420 // Getter Methods 0421 // ----------------------------------------------------------------------- 0422 /** @name Getter Methods (Xerces-C specific) */ 0423 //@{ 0424 /** 0425 * This method is used to get the current validator. 0426 * 0427 * <b>SAX2XMLReader assumes responsibility for the validator. It will be 0428 * deleted when the XMLReader is destroyed.</b> 0429 * 0430 * @return A pointer to the validator. An application should not deleted 0431 * the object returned. 0432 * 0433 */ 0434 virtual XMLValidator* getValidator() const = 0; 0435 0436 /** Get error count from the last parse operation. 0437 * 0438 * This method returns the error count from the last parse 0439 * operation. Note that this count is actually stored in the 0440 * scanner, so this method simply returns what the 0441 * scanner reports. 0442 * 0443 * @return number of errors encountered during the latest 0444 * parse operation. 0445 */ 0446 virtual XMLSize_t getErrorCount() const = 0 ; 0447 0448 /** 0449 * This method returns the state of the parser's 0450 * exit-on-First-Fatal-Error flag. 0451 * 0452 * <p>Or you can query the feature "http://apache.org/xml/features/continue-after-fatal-error" 0453 * which indicates the opposite state.</p> 0454 * 0455 * @return true, if the parser is currently configured to 0456 * exit on the first fatal error, false otherwise. 0457 * 0458 * @see #setExitOnFirstFatalError 0459 * @see #getFeature 0460 */ 0461 virtual bool getExitOnFirstFatalError() const = 0; 0462 0463 /** 0464 * This method returns the state of the parser's 0465 * validation-constraint-fatal flag. 0466 * 0467 * <p>Or you can query the feature "http://apache.org/xml/features/validation-error-as-fatal" 0468 * which means the same thing. 0469 * 0470 * @return true, if the parser is currently configured to 0471 * set validation constraint errors as fatal, false 0472 * otherwise. 0473 * 0474 * @see #setValidationConstraintFatal 0475 * @see #getFeature 0476 */ 0477 virtual bool getValidationConstraintFatal() const = 0; 0478 0479 /** 0480 * Retrieve the grammar that is associated with the specified namespace key 0481 * 0482 * @param nameSpaceKey Namespace key 0483 * @return Grammar associated with the Namespace key. 0484 */ 0485 virtual Grammar* getGrammar(const XMLCh* const nameSpaceKey) = 0; 0486 0487 /** 0488 * Retrieve the grammar where the root element is declared. 0489 * 0490 * @return Grammar where root element declared 0491 */ 0492 virtual Grammar* getRootGrammar() = 0; 0493 0494 /** 0495 * Returns the string corresponding to a URI id from the URI string pool. 0496 * 0497 * @param uriId id of the string in the URI string pool. 0498 * @return URI string corresponding to the URI id. 0499 */ 0500 virtual const XMLCh* getURIText(unsigned int uriId) const = 0; 0501 0502 /** 0503 * Returns the current src offset within the input source. 0504 * To be used only while parsing is in progress. 0505 * 0506 * @return offset within the input source 0507 */ 0508 virtual XMLFilePos getSrcOffset() const = 0; 0509 0510 //@} 0511 0512 // ----------------------------------------------------------------------- 0513 // Setter Methods 0514 // ----------------------------------------------------------------------- 0515 /** @name Setter Methods (Xerces-C specific) */ 0516 //@{ 0517 /** 0518 * This method is used to set a validator. 0519 * 0520 * <b>SAX2XMLReader assumes responsibility for the validator. It will be 0521 * deleted when the XMLReader is destroyed.</b> 0522 * 0523 * @param valueToAdopt A pointer to the validator that the reader should use. 0524 * 0525 */ 0526 virtual void setValidator(XMLValidator* valueToAdopt) = 0; 0527 0528 /** 0529 * This method allows users to set the parser's behaviour when it 0530 * encounters the first fatal error. If set to true, the parser 0531 * will exit at the first fatal error. If false, then it will 0532 * report the error and continue processing. 0533 * 0534 * <p>The default value is 'true' and the parser exits on the 0535 * first fatal error.</p> 0536 * 0537 * <p>Or you can set the feature "http://apache.org/xml/features/continue-after-fatal-error" 0538 * which has the opposite behaviour.</p> 0539 * 0540 * <p>If both the feature above and this function are used, the latter takes effect.</p> 0541 * 0542 * @param newState The value specifying whether the parser should 0543 * continue or exit when it encounters the first 0544 * fatal error. 0545 * 0546 * @see #getExitOnFirstFatalError 0547 * @see #setFeature 0548 */ 0549 virtual void setExitOnFirstFatalError(const bool newState) = 0; 0550 0551 /** 0552 * This method allows users to set the parser's behaviour when it 0553 * encounters a validation constraint error. If set to true, and the 0554 * the parser will treat validation error as fatal and will exit depends on the 0555 * state of "getExitOnFirstFatalError". If false, then it will 0556 * report the error and continue processing. 0557 * 0558 * Note: setting this true does not mean the validation error will be printed with 0559 * the word "Fatal Error". It is still printed as "Error", but the parser 0560 * will exit if "setExitOnFirstFatalError" is set to true. 0561 * 0562 * <p>The default value is 'false'.</p> 0563 * 0564 * <p>Or you can set the feature "http://apache.org/xml/features/validation-error-as-fatal" 0565 * which means the same thing.</p> 0566 * 0567 * <p>If both the feature above and this function are used, the latter takes effect.</p> 0568 * 0569 * @param newState If true, the parser will exit if "setExitOnFirstFatalError" 0570 * is set to true. 0571 * 0572 * @see #getValidationConstraintFatal 0573 * @see #setExitOnFirstFatalError 0574 * @see #setFeature 0575 */ 0576 virtual void setValidationConstraintFatal(const bool newState) = 0; 0577 //@} 0578 0579 0580 // ----------------------------------------------------------------------- 0581 // Progressive scan methods 0582 // ----------------------------------------------------------------------- 0583 0584 /** @name Progressive scan methods */ 0585 //@{ 0586 0587 /** Begin a progressive parse operation 0588 * 0589 * This method is used to start a progressive parse on a XML file. 0590 * To continue parsing, subsequent calls must be to the parseNext 0591 * method. 0592 * 0593 * It scans through the prolog and returns a token to be used on 0594 * subsequent scanNext() calls. If the return value is true, then the 0595 * token is legal and ready for further use. If it returns false, then 0596 * the scan of the prolog failed and the token is not going to work on 0597 * subsequent scanNext() calls. 0598 * 0599 * @param systemId A pointer to a Unicode string representing the path 0600 * to the XML file to be parsed. 0601 * @param toFill A token maintaing state information to maintain 0602 * internal consistency between invocation of 'parseNext' 0603 * calls. 0604 * 0605 * @return 'true', if successful in parsing the prolog. It indicates the 0606 * user can go ahead with parsing the rest of the file. It 0607 * returns 'false' to indicate that the parser could parse the 0608 * prolog (which means the token will not be valid.) 0609 * 0610 * @see #parseNext 0611 * @see #parseFirst(char*,...) 0612 * @see #parseFirst(InputSource&,...) 0613 */ 0614 virtual bool parseFirst 0615 ( 0616 const XMLCh* const systemId 0617 , XMLPScanToken& toFill 0618 ) = 0; 0619 0620 /** Begin a progressive parse operation 0621 * 0622 * This method is used to start a progressive parse on a XML file. 0623 * To continue parsing, subsequent calls must be to the parseNext 0624 * method. 0625 * 0626 * It scans through the prolog and returns a token to be used on 0627 * subsequent scanNext() calls. If the return value is true, then the 0628 * token is legal and ready for further use. If it returns false, then 0629 * the scan of the prolog failed and the token is not going to work on 0630 * subsequent scanNext() calls. 0631 * 0632 * @param systemId A pointer to a regular native string representing 0633 * the path to the XML file to be parsed. 0634 * @param toFill A token maintaing state information to maintain 0635 * internal consistency between invocation of 'parseNext' 0636 * calls. 0637 * 0638 * @return 'true', if successful in parsing the prolog. It indicates the 0639 * user can go ahead with parsing the rest of the file. It 0640 * returns 'false' to indicate that the parser could not parse 0641 * the prolog. 0642 * 0643 * @see #parseNext 0644 * @see #parseFirst(XMLCh*,...) 0645 * @see #parseFirst(InputSource&,...) 0646 */ 0647 virtual bool parseFirst 0648 ( 0649 const char* const systemId 0650 , XMLPScanToken& toFill 0651 ) = 0; 0652 0653 /** Begin a progressive parse operation 0654 * 0655 * This method is used to start a progressive parse on a XML file. 0656 * To continue parsing, subsequent calls must be to the parseNext 0657 * method. 0658 * 0659 * It scans through the prolog and returns a token to be used on 0660 * subsequent scanNext() calls. If the return value is true, then the 0661 * token is legal and ready for further use. If it returns false, then 0662 * the scan of the prolog failed and the token is not going to work on 0663 * subsequent scanNext() calls. 0664 * 0665 * @param source A const reference to the InputSource object which 0666 * points to the XML file to be parsed. 0667 * @param toFill A token maintaing state information to maintain 0668 * internal consistency between invocation of 'parseNext' 0669 * calls. 0670 * 0671 * @return 'true', if successful in parsing the prolog. It indicates the 0672 * user can go ahead with parsing the rest of the file. It 0673 * returns 'false' to indicate that the parser could not parse 0674 * the prolog. 0675 * 0676 * @see #parseNext 0677 * @see #parseFirst(XMLCh*,...) 0678 * @see #parseFirst(char*,...) 0679 */ 0680 virtual bool parseFirst 0681 ( 0682 const InputSource& source 0683 , XMLPScanToken& toFill 0684 ) = 0; 0685 0686 /** Continue a progressive parse operation 0687 * 0688 * This method is used to continue with progressive parsing of 0689 * XML files started by a call to 'parseFirst' method. 0690 * 0691 * It parses the XML file and stops as soon as it comes across 0692 * a XML token (as defined in the XML specification). Relevant 0693 * callback handlers are invoked as required by the SAX 0694 * specification. 0695 * 0696 * @param token A token maintaing state information to maintain 0697 * internal consistency between invocation of 'parseNext' 0698 * calls. 0699 * 0700 * @return 'true', if successful in parsing the next XML token. 0701 * It indicates the user can go ahead with parsing the rest 0702 * of the file. It returns 'false' to indicate that the parser 0703 * could not find next token as per the XML specification 0704 * production rule. 0705 * 0706 * @see #parseFirst(XMLCh*,...) 0707 * @see #parseFirst(char*,...) 0708 * @see #parseFirst(InputSource&,...) 0709 */ 0710 virtual bool parseNext(XMLPScanToken& token) = 0; 0711 0712 /** Reset the parser after a progressive parse 0713 * 0714 * If a progressive parse loop exits before the end of the document 0715 * is reached, the parser has no way of knowing this. So it will leave 0716 * open any files or sockets or memory buffers that were in use at 0717 * the time that the parse loop exited. 0718 * 0719 * The next parse operation will cause these open files and such to 0720 * be closed, but the next parse operation might occur at some unknown 0721 * future point. To avoid this problem, you should reset the parser if 0722 * you exit the loop early. 0723 * 0724 * If you exited because of an error, then this cleanup will be done 0725 * for you. Its only when you exit the file prematurely of your own 0726 * accord, because you've found what you wanted in the file most 0727 * likely. 0728 * 0729 * @param token A token maintaing state information to maintain 0730 * internal consistency between invocation of 'parseNext' 0731 * calls. 0732 */ 0733 virtual void parseReset(XMLPScanToken& token) = 0; 0734 0735 //@} 0736 0737 // ----------------------------------------------------------------------- 0738 // Grammar preparsing interface 0739 // ----------------------------------------------------------------------- 0740 0741 /** @name Grammar preparsing interface's. */ 0742 //@{ 0743 /** 0744 * Preparse schema grammar (XML Schema, DTD, etc.) via an input source 0745 * object. 0746 * 0747 * This method invokes the preparsing process on a schema grammar XML 0748 * file specified by the SAX InputSource parameter. If the 'toCache' flag 0749 * is enabled, the parser will cache the grammars for re-use. If a grammar 0750 * key is found in the pool, no caching of any grammar will take place. 0751 * 0752 * 0753 * @param source A const reference to the SAX InputSource object which 0754 * points to the schema grammar file to be preparsed. 0755 * @param grammarType The grammar type (Schema or DTD). 0756 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0757 * otherwise, no caching. Default is <code>false</code>. 0758 * @return The preparsed schema grammar object (SchemaGrammar or 0759 * DTDGrammar). That grammar object is owned by the parser. 0760 * 0761 * @exception SAXException Any SAX exception, possibly 0762 * wrapping another exception. 0763 * @exception XMLException An exception from the parser or client 0764 * handler code. 0765 * @exception DOMException A DOM exception as per DOM spec. 0766 * 0767 * @see InputSource#InputSource 0768 */ 0769 virtual Grammar* loadGrammar(const InputSource& source, 0770 const Grammar::GrammarType grammarType, 0771 const bool toCache = false) = 0; 0772 0773 /** 0774 * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL 0775 * 0776 * This method invokes the preparsing process on a schema grammar XML 0777 * file specified by the file path parameter. If the 'toCache' flag 0778 * is enabled, the parser will cache the grammars for re-use. If a grammar 0779 * key is found in the pool, no caching of any grammar will take place. 0780 * 0781 * 0782 * @param systemId A const XMLCh pointer to the Unicode string which 0783 * contains the path to the XML grammar file to be 0784 * preparsed. 0785 * @param grammarType The grammar type (Schema or DTD). 0786 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0787 * otherwise, no caching. Default is <code>false</code>. 0788 * @return The preparsed schema grammar object (SchemaGrammar or 0789 * DTDGrammar). That grammar object is owned by the parser. 0790 * 0791 * @exception SAXException Any SAX exception, possibly 0792 * wrapping another exception. 0793 * @exception XMLException An exception from the parser or client 0794 * handler code. 0795 * @exception DOMException A DOM exception as per DOM spec. 0796 */ 0797 virtual Grammar* loadGrammar(const XMLCh* const systemId, 0798 const Grammar::GrammarType grammarType, 0799 const bool toCache = false) = 0; 0800 0801 /** 0802 * Preparse schema grammar (XML Schema, DTD, etc.) via a file path or URL 0803 * 0804 * This method invokes the preparsing process on a schema grammar XML 0805 * file specified by the file path parameter. If the 'toCache' flag 0806 * is enabled, the parser will cache the grammars for re-use. If a grammar 0807 * key is found in the pool, no caching of any grammar will take place. 0808 * 0809 * 0810 * @param systemId A const char pointer to a native string which contains 0811 * the path to the XML grammar file to be preparsed. 0812 * @param grammarType The grammar type (Schema or DTD). 0813 * @param toCache If <code>true</code>, we cache the preparsed grammar, 0814 * otherwise, no caching. Default is <code>false</code>. 0815 * @return The preparsed schema grammar object (SchemaGrammar or 0816 * DTDGrammar). That grammar object is owned by the parser. 0817 * 0818 * @exception SAXException Any SAX exception, possibly 0819 * wrapping another exception. 0820 * @exception XMLException An exception from the parser or client 0821 * handler code. 0822 * @exception DOMException A DOM exception as per DOM spec. 0823 */ 0824 virtual Grammar* loadGrammar(const char* const systemId, 0825 const Grammar::GrammarType grammarType, 0826 const bool toCache = false) = 0; 0827 0828 /** 0829 * Clear the cached grammar pool 0830 */ 0831 virtual void resetCachedGrammarPool() = 0; 0832 0833 /** Set maximum input buffer size 0834 * 0835 * This method allows users to limit the size of buffers used in parsing 0836 * XML character data. The effect of setting this size is to limit the 0837 * size of a ContentHandler::characters() call. 0838 * 0839 * The parser's default input buffer size is 1 megabyte. 0840 * 0841 * @param bufferSize The maximum input buffer size 0842 */ 0843 virtual void setInputBufferSize(const XMLSize_t bufferSize); 0844 0845 //@} 0846 0847 0848 // ----------------------------------------------------------------------- 0849 // Advanced document handler list maintenance methods 0850 // ----------------------------------------------------------------------- 0851 0852 /** @name Advanced document handler list maintenance methods */ 0853 //@{ 0854 /** 0855 * This method installs the specified 'advanced' document callback 0856 * handler, thereby allowing the user to customize the processing, 0857 * if they choose to do so. Any number of advanced callback handlers 0858 * maybe installed. 0859 * 0860 * <p>The methods in the advanced callback interface represent 0861 * Xerces-C extensions. There is no specification for this interface.</p> 0862 * 0863 * @param toInstall A pointer to the users advanced callback handler. 0864 * 0865 * @see #removeAdvDocHandler 0866 */ 0867 virtual void installAdvDocHandler(XMLDocumentHandler* const toInstall) = 0; 0868 0869 /** 0870 * This method removes the 'advanced' document handler callback from 0871 * the underlying parser scanner. If no handler is installed, advanced 0872 * callbacks are not invoked by the scanner. 0873 * @param toRemove A pointer to the advanced callback handler which 0874 * should be removed. 0875 * 0876 * @see #installAdvDocHandler 0877 */ 0878 virtual bool removeAdvDocHandler(XMLDocumentHandler* const toRemove) = 0; 0879 //@} 0880 0881 private : 0882 /* The copy constructor, you cannot call this directly */ 0883 SAX2XMLReader(const SAX2XMLReader&); 0884 0885 /* The assignment operator, you cannot call this directly */ 0886 SAX2XMLReader& operator=(const SAX2XMLReader&); 0887 0888 }; 0889 0890 inline void SAX2XMLReader::setInputBufferSize(const XMLSize_t /*bufferSize*/) 0891 { 0892 } 0893 0894 XERCES_CPP_NAMESPACE_END 0895 0896 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |