|
|
|||
File indexing completed on 2025-12-16 10:34:14
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_HANDLERBASE_HPP) 0023 #define XERCESC_INCLUDE_GUARD_HANDLERBASE_HPP 0024 0025 #include <xercesc/sax/DocumentHandler.hpp> 0026 #include <xercesc/sax/DTDHandler.hpp> 0027 #include <xercesc/sax/EntityResolver.hpp> 0028 #include <xercesc/sax/ErrorHandler.hpp> 0029 #include <xercesc/sax/SAXParseException.hpp> 0030 0031 XERCES_CPP_NAMESPACE_BEGIN 0032 0033 class Locator; 0034 class AttributeList; 0035 0036 /** 0037 * Default base class for handlers. 0038 * 0039 * <p>This class implements the default behaviour for four SAX 0040 * interfaces: EntityResolver, DTDHandler, DocumentHandler, 0041 * and ErrorHandler.</p> 0042 * 0043 * <p>Application writers can extend this class when they need to 0044 * implement only part of an interface; parser writers can 0045 * instantiate this class to provide default handlers when the 0046 * application has not supplied its own.</p> 0047 * 0048 * <p>Note that the use of this class is optional.</p> 0049 * 0050 * @see EntityResolver#EntityResolver 0051 * @see DTDHandler#DTDHandler 0052 * @see DocumentHandler#DocumentHandler 0053 * @see ErrorHandler#ErrorHandler 0054 */ 0055 0056 class SAX_EXPORT HandlerBase : 0057 0058 public EntityResolver, public DTDHandler, public DocumentHandler 0059 , public ErrorHandler 0060 { 0061 public: 0062 /** @name Default handlers for the DocumentHandler interface */ 0063 //@{ 0064 /** 0065 * Receive notification of character data inside an element. 0066 * 0067 * <p>By default, do nothing. Application writers may override this 0068 * method to take specific actions for each chunk of character data 0069 * (such as adding the data to a node or buffer, or printing it to 0070 * a file).</p> 0071 * 0072 * @param chars The characters. 0073 * @param length The number of characters to use from the 0074 * character array. 0075 * @exception SAXException Any SAX exception, possibly 0076 * wrapping another exception. 0077 * @see DocumentHandler#characters 0078 */ 0079 virtual void characters 0080 ( 0081 const XMLCh* const chars 0082 , const XMLSize_t length 0083 ); 0084 0085 /** 0086 * Receive notification of the end of the document. 0087 * 0088 * <p>By default, do nothing. Application writers may override this 0089 * method in a subclass to take specific actions at the beginning 0090 * of a document (such as finalising a tree or closing an output 0091 * file).</p> 0092 * 0093 * @exception SAXException Any SAX exception, possibly 0094 * wrapping another exception. 0095 * @see DocumentHandler#endDocument 0096 */ 0097 virtual void endDocument(); 0098 0099 /** 0100 * Receive notification of the end of an element. 0101 * 0102 * <p>By default, do nothing. Application writers may override this 0103 * method in a subclass to take specific actions at the end of 0104 * each element (such as finalising a tree node or writing 0105 * output to a file).</p> 0106 * 0107 * @param name The element type name. 0108 * @exception SAXException Any SAX exception, possibly 0109 * wrapping another exception. 0110 * @see DocumentHandler#endElement 0111 */ 0112 virtual void endElement(const XMLCh* const name); 0113 0114 /** 0115 * Receive notification of ignorable whitespace in element content. 0116 * 0117 * <p>By default, do nothing. Application writers may override this 0118 * method to take specific actions for each chunk of ignorable 0119 * whitespace (such as adding data to a node or buffer, or printing 0120 * it to a file).</p> 0121 * 0122 * @param chars The whitespace characters. 0123 * @param length The number of characters to use from the 0124 * character array. 0125 * @exception SAXException Any SAX exception, possibly 0126 * wrapping another exception. 0127 * @see DocumentHandler#ignorableWhitespace 0128 */ 0129 virtual void ignorableWhitespace 0130 ( 0131 const XMLCh* const chars 0132 , const XMLSize_t length 0133 ); 0134 0135 /** 0136 * Receive notification of a processing instruction. 0137 * 0138 * <p>By default, do nothing. Application writers may override this 0139 * method in a subclass to take specific actions for each 0140 * processing instruction, such as setting status variables or 0141 * invoking other methods.</p> 0142 * 0143 * @param target The processing instruction target. 0144 * @param data The processing instruction data, or null if 0145 * none is supplied. 0146 * @exception SAXException Any SAX exception, possibly 0147 * wrapping another exception. 0148 * @see DocumentHandler#processingInstruction 0149 */ 0150 virtual void processingInstruction 0151 ( 0152 const XMLCh* const target 0153 , const XMLCh* const data 0154 ); 0155 0156 /** 0157 * Reset the Document object on its reuse 0158 * 0159 * @see DocumentHandler#resetDocument 0160 */ 0161 virtual void resetDocument(); 0162 //@} 0163 0164 /** @name Default implementation of DocumentHandler interface */ 0165 0166 //@{ 0167 /** 0168 * Receive a Locator object for document events. 0169 * 0170 * <p>By default, do nothing. Application writers may override this 0171 * method in a subclass if they wish to store the locator for use 0172 * with other document events.</p> 0173 * 0174 * @param locator A locator for all SAX document events. 0175 * @see DocumentHandler#setDocumentLocator 0176 * @see Locator 0177 */ 0178 virtual void setDocumentLocator(const Locator* const locator); 0179 0180 /** 0181 * Receive notification of the beginning of the document. 0182 * 0183 * <p>By default, do nothing. Application writers may override this 0184 * method in a subclass to take specific actions at the beginning 0185 * of a document (such as allocating the root node of a tree or 0186 * creating an output file).</p> 0187 * 0188 * @exception SAXException Any SAX exception, possibly 0189 * wrapping another exception. 0190 * @see DocumentHandler#startDocument 0191 */ 0192 virtual void startDocument(); 0193 0194 /** 0195 * Receive notification of the start of an element. 0196 * 0197 * <p>By default, do nothing. Application writers may override this 0198 * method in a subclass to take specific actions at the start of 0199 * each element (such as allocating a new tree node or writing 0200 * output to a file).</p> 0201 * 0202 * @param name The element type name. 0203 * @param attributes The specified or defaulted attributes. 0204 * @exception SAXException Any SAX exception, possibly 0205 * wrapping another exception. 0206 * @see DocumentHandler#startElement 0207 */ 0208 virtual void startElement 0209 ( 0210 const XMLCh* const name 0211 , AttributeList& attributes 0212 ); 0213 0214 //@} 0215 0216 /** @name Default implementation of the EntityResolver interface. */ 0217 0218 //@{ 0219 /** 0220 * Resolve an external entity. 0221 * 0222 * <p>Always return null, so that the parser will use the system 0223 * identifier provided in the XML document. This method implements 0224 * the SAX default behaviour: application writers can override it 0225 * in a subclass to do special translations such as catalog lookups 0226 * or URI redirection.</p> 0227 * 0228 * @param publicId The public identifier, or null if none is 0229 * available. 0230 * @param systemId The system identifier provided in the XML 0231 * document. 0232 * @return The new input source, or null to require the 0233 * default behaviour. 0234 * The returned InputSource is owned by the parser which is 0235 * responsible to clean up the memory. 0236 * @exception SAXException Any SAX exception, possibly 0237 * wrapping another exception. 0238 * @see EntityResolver#resolveEntity 0239 */ 0240 virtual InputSource* resolveEntity 0241 ( 0242 const XMLCh* const publicId 0243 , const XMLCh* const systemId 0244 ); 0245 0246 //@} 0247 0248 /** @name Default implementation of the ErrorHandler interface */ 0249 //@{ 0250 /** 0251 * Receive notification of a recoverable parser error. 0252 * 0253 * <p>The default implementation does nothing. Application writers 0254 * may override this method in a subclass to take specific actions 0255 * for each error, such as inserting the message in a log file or 0256 * printing it to the console.</p> 0257 * 0258 * @param exc The warning information encoded as an exception. 0259 * @exception SAXException Any SAX exception, possibly 0260 * wrapping another exception. 0261 * @see ErrorHandler#warning 0262 * @see SAXParseException#SAXParseException 0263 */ 0264 virtual void error(const SAXParseException& exc); 0265 0266 /** 0267 * Report a fatal XML parsing error. 0268 * 0269 * <p>The default implementation throws a SAXParseException. 0270 * Application writers may override this method in a subclass if 0271 * they need to take specific actions for each fatal error (such as 0272 * collecting all of the errors into a single report): in any case, 0273 * the application must stop all regular processing when this 0274 * method is invoked, since the document is no longer reliable, and 0275 * the parser may no longer report parsing events.</p> 0276 * 0277 * @param exc The error information encoded as an exception. 0278 * @exception SAXException Any SAX exception, possibly 0279 * wrapping another exception. 0280 * @see ErrorHandler#fatalError 0281 * @see SAXParseException#SAXParseException 0282 */ 0283 virtual void fatalError(const SAXParseException& exc); 0284 0285 /** 0286 * Receive notification of a parser warning. 0287 * 0288 * <p>The default implementation does nothing. Application writers 0289 * may override this method in a subclass to take specific actions 0290 * for each warning, such as inserting the message in a log file or 0291 * printing it to the console.</p> 0292 * 0293 * @param exc The warning information encoded as an exception. 0294 * @exception SAXException Any SAX exception, possibly 0295 * wrapping another exception. 0296 * @see ErrorHandler#warning 0297 * @see SAXParseException#SAXParseException 0298 */ 0299 virtual void warning(const SAXParseException& exc); 0300 0301 /** 0302 * Reset the Error handler object on its reuse 0303 * 0304 * @see ErrorHandler#resetErrors 0305 */ 0306 virtual void resetErrors(); 0307 0308 //@} 0309 0310 0311 /** @name Default implementation of DTDHandler interface. */ 0312 //@{ 0313 0314 /** 0315 * Receive notification of a notation declaration. 0316 * 0317 * <p>By default, do nothing. Application writers may override this 0318 * method in a subclass if they wish to keep track of the notations 0319 * declared in a document.</p> 0320 * 0321 * @param name The notation name. 0322 * @param publicId The notation public identifier, or null if not 0323 * available. 0324 * @param systemId The notation system identifier. 0325 * @see DTDHandler#notationDecl 0326 */ 0327 virtual void notationDecl 0328 ( 0329 const XMLCh* const name 0330 , const XMLCh* const publicId 0331 , const XMLCh* const systemId 0332 ); 0333 0334 /** 0335 * Reset the DTD object on its reuse 0336 * 0337 * @see DTDHandler#resetDocType 0338 */ 0339 virtual void resetDocType(); 0340 0341 /** 0342 * Receive notification of an unparsed entity declaration. 0343 * 0344 * <p>By default, do nothing. Application writers may override this 0345 * method in a subclass to keep track of the unparsed entities 0346 * declared in a document.</p> 0347 * 0348 * @param name The entity name. 0349 * @param publicId The entity public identifier, or null if not 0350 * available. 0351 * @param systemId The entity system identifier. 0352 * @param notationName The name of the associated notation. 0353 * @see DTDHandler#unparsedEntityDecl 0354 */ 0355 virtual void unparsedEntityDecl 0356 ( 0357 const XMLCh* const name 0358 , const XMLCh* const publicId 0359 , const XMLCh* const systemId 0360 , const XMLCh* const notationName 0361 ); 0362 //@} 0363 0364 HandlerBase() {}; 0365 virtual ~HandlerBase() {}; 0366 0367 private: 0368 // ----------------------------------------------------------------------- 0369 // Unimplemented constructors and operators 0370 // ----------------------------------------------------------------------- 0371 HandlerBase(const HandlerBase&); 0372 HandlerBase& operator=(const HandlerBase&); 0373 }; 0374 0375 0376 // --------------------------------------------------------------------------- 0377 // HandlerBase: Inline default implementations 0378 // --------------------------------------------------------------------------- 0379 inline void HandlerBase::characters(const XMLCh* const 0380 , const XMLSize_t) 0381 { 0382 } 0383 0384 inline void HandlerBase::endDocument() 0385 { 0386 } 0387 0388 inline void HandlerBase::endElement(const XMLCh* const) 0389 { 0390 } 0391 0392 inline void HandlerBase::error(const SAXParseException&) 0393 { 0394 } 0395 0396 inline void HandlerBase::fatalError(const SAXParseException& exc) 0397 { 0398 throw exc; 0399 } 0400 0401 inline void 0402 HandlerBase::ignorableWhitespace( const XMLCh* const 0403 , const XMLSize_t) 0404 { 0405 } 0406 0407 inline void HandlerBase::notationDecl( const XMLCh* const 0408 , const XMLCh* const 0409 , const XMLCh* const) 0410 { 0411 } 0412 0413 inline void 0414 HandlerBase::processingInstruction( const XMLCh* const 0415 , const XMLCh* const) 0416 { 0417 } 0418 0419 inline void HandlerBase::resetErrors() 0420 { 0421 } 0422 0423 inline void HandlerBase::resetDocument() 0424 { 0425 } 0426 0427 inline void HandlerBase::resetDocType() 0428 { 0429 } 0430 0431 inline InputSource* 0432 HandlerBase::resolveEntity( const XMLCh* const 0433 , const XMLCh* const) 0434 { 0435 return 0; 0436 } 0437 0438 inline void 0439 HandlerBase::unparsedEntityDecl(const XMLCh* const 0440 , const XMLCh* const 0441 , const XMLCh* const 0442 , const XMLCh* const) 0443 { 0444 } 0445 0446 inline void HandlerBase::setDocumentLocator(const Locator* const) 0447 { 0448 } 0449 0450 inline void HandlerBase::startDocument() 0451 { 0452 } 0453 0454 inline void 0455 HandlerBase::startElement( const XMLCh* const 0456 , AttributeList&) 0457 { 0458 } 0459 0460 inline void HandlerBase::warning(const SAXParseException&) 0461 { 0462 } 0463 0464 XERCES_CPP_NAMESPACE_END 0465 0466 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|