|
||||
File indexing completed on 2025-01-30 10:27:09
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_CONTENTHANDLER_HPP) 0023 #define XERCESC_INCLUDE_GUARD_CONTENTHANDLER_HPP 0024 0025 #include <xercesc/util/XercesDefs.hpp> 0026 0027 XERCES_CPP_NAMESPACE_BEGIN 0028 0029 class Attributes; 0030 class Locator; 0031 0032 /** 0033 * Receive notification of general document events. 0034 * 0035 * <p>This is the main interface that most SAX2 applications 0036 * implement: if the application needs to be informed of basic parsing 0037 * events, it implements this interface and registers an instance with 0038 * the SAX2 parser using the setDocumentHandler method. The parser 0039 * uses the instance to report basic document-related events like 0040 * the start and end of elements and character data.</p> 0041 * 0042 * <p>The order of events in this interface is very important, and 0043 * mirrors the order of information in the document itself. For 0044 * example, all of an element's content (character data, processing 0045 * instructions, and/or subelements) will appear, in order, between 0046 * the startElement event and the corresponding endElement event.</p> 0047 * 0048 * <p>Application writers who do not want to implement the entire 0049 * interface while can derive a class from Sax2HandlerBase, which implements 0050 * the default functionality; parser writers can instantiate 0051 * Sax2HandlerBase to obtain a default handler. The application can find 0052 * the location of any document event using the Locator interface 0053 * supplied by the Parser through the setDocumentLocator method.</p> 0054 * 0055 * @see Parser#setDocumentHandler 0056 * @see Locator#Locator 0057 * @see Sax2HandlerBase#Sax2HandlerBase 0058 */ 0059 0060 class SAX2_EXPORT ContentHandler 0061 { 0062 public: 0063 /** @name Constructors and Destructor */ 0064 //@{ 0065 /** Default constructor */ 0066 ContentHandler() 0067 { 0068 } 0069 0070 /** Destructor */ 0071 virtual ~ContentHandler() 0072 { 0073 } 0074 //@} 0075 0076 /** @name The virtual document handler interface */ 0077 0078 //@{ 0079 /** 0080 * Receive notification of character data. 0081 * 0082 * <p>The Parser will call this method to report each chunk of 0083 * character data. SAX parsers may return all contiguous character 0084 * data in a single chunk, or they may split it into several 0085 * chunks; however, all of the characters in any single event 0086 * must come from the same external entity, so that the Locator 0087 * provides useful information.</p> 0088 * 0089 * <p>The application must not attempt to read from the array 0090 * outside of the specified range.</p> 0091 * 0092 * <p>Note that some parsers will report whitespace using the 0093 * ignorableWhitespace() method rather than this one (validating 0094 * parsers must do so).</p> 0095 * 0096 * @param chars The characters from the XML document. 0097 * @param length The number of characters to read from the array. 0098 * @exception SAXException Any SAX exception, possibly 0099 * wrapping another exception. 0100 * @see #ignorableWhitespace 0101 * @see Locator#Locator 0102 */ 0103 virtual void characters 0104 ( 0105 const XMLCh* const chars 0106 , const XMLSize_t length 0107 ) = 0; 0108 0109 /** 0110 * Receive notification of the end of a document. 0111 * 0112 * <p>The SAX parser will invoke this method only once, and it will 0113 * be the last method invoked during the parse. The parser shall 0114 * not invoke this method until it has either abandoned parsing 0115 * (because of an unrecoverable error) or reached the end of 0116 * input.</p> 0117 * 0118 * @exception SAXException Any SAX exception, possibly 0119 * wrapping another exception. 0120 */ 0121 virtual void endDocument () = 0; 0122 0123 /** 0124 * Receive notification of the end of an element. 0125 * 0126 * <p>The SAX parser will invoke this method at the end of every 0127 * element in the XML document; there will be a corresponding 0128 * startElement() event for every endElement() event (even when the 0129 * element is empty).</p> 0130 * 0131 * @param uri The URI of the associated namespace for this element 0132 * @param localname The local part of the element name 0133 * @param qname The QName of this element 0134 * @exception SAXException Any SAX exception, possibly 0135 * wrapping another exception. 0136 */ 0137 virtual void endElement 0138 ( 0139 const XMLCh* const uri, 0140 const XMLCh* const localname, 0141 const XMLCh* const qname 0142 ) = 0; 0143 0144 /** 0145 * Receive notification of ignorable whitespace in element content. 0146 * 0147 * <p>Validating Parsers must use this method to report each chunk 0148 * of ignorable whitespace (see the W3C XML 1.0 recommendation, 0149 * section 2.10): non-validating parsers may also use this method 0150 * if they are capable of parsing and using content models.</p> 0151 * 0152 * <p>SAX parsers may return all contiguous whitespace in a single 0153 * chunk, or they may split it into several chunks; however, all of 0154 * the characters in any single event must come from the same 0155 * external entity, so that the Locator provides useful 0156 * information.</p> 0157 * 0158 * <p>The application must not attempt to read from the array 0159 * outside of the specified range.</p> 0160 * 0161 * @param chars The characters from the XML document. 0162 * @param length The number of characters to read from the array. 0163 * @exception SAXException Any SAX exception, possibly 0164 * wrapping another exception. 0165 * @see #characters 0166 */ 0167 virtual void ignorableWhitespace 0168 ( 0169 const XMLCh* const chars 0170 , const XMLSize_t length 0171 ) = 0; 0172 0173 /** 0174 * Receive notification of a processing instruction. 0175 * 0176 * <p>The Parser will invoke this method once for each processing 0177 * instruction found: note that processing instructions may occur 0178 * before or after the main document element.</p> 0179 * 0180 * <p>A SAX parser should never report an XML declaration (XML 1.0, 0181 * section 2.8) or a text declaration (XML 1.0, section 4.3.1) 0182 * using this method.</p> 0183 * 0184 * @param target The processing instruction target. 0185 * @param data The processing instruction data, or null if 0186 * none was supplied. 0187 * @exception SAXException Any SAX exception, possibly 0188 * wrapping another exception. 0189 */ 0190 virtual void processingInstruction 0191 ( 0192 const XMLCh* const target 0193 , const XMLCh* const data 0194 ) = 0; 0195 0196 /** 0197 * Receive an object for locating the origin of SAX document events. 0198 * 0199 * SAX parsers are strongly encouraged (though not absolutely 0200 * required) to supply a locator: if it does so, it must supply 0201 * the locator to the application by invoking this method before 0202 * invoking any of the other methods in the DocumentHandler 0203 * interface. 0204 * 0205 * The locator allows the application to determine the end 0206 * position of any document-related event, even if the parser is 0207 * not reporting an error. Typically, the application will 0208 * use this information for reporting its own errors (such as 0209 * character content that does not match an application's 0210 * business rules). The information returned by the locator 0211 * is probably not sufficient for use with a search engine. 0212 * 0213 * Note that the locator will return correct information only 0214 * during the invocation of the events in this interface. The 0215 * application should not attempt to use it at any other time. 0216 * 0217 * @param locator An object that can return the location of 0218 * any SAX document event. The object is only 0219 * 'on loan' to the client code and they are not 0220 * to attempt to delete or modify it in any way! 0221 * 0222 * @see Locator#Locator 0223 */ 0224 virtual void setDocumentLocator(const Locator* const locator) = 0; 0225 0226 /** 0227 * Receive notification of the beginning of a document. 0228 * 0229 * <p>The SAX parser will invoke this method only once, before any 0230 * other methods in this interface or in DTDHandler (except for 0231 * setDocumentLocator).</p> 0232 * 0233 * @exception SAXException Any SAX exception, possibly 0234 * wrapping another exception. 0235 */ 0236 virtual void startDocument() = 0; 0237 0238 /** 0239 * Receive notification of the beginning of an element. 0240 * 0241 * <p>The Parser will invoke this method at the beginning of every 0242 * element in the XML document; there will be a corresponding 0243 * endElement() event for every startElement() event (even when the 0244 * element is empty). All of the element's content will be 0245 * reported, in order, before the corresponding endElement() 0246 * event.</p> 0247 * 0248 * <p>Note that the attribute list provided will 0249 * contain only attributes with explicit values (specified or 0250 * defaulted): \#IMPLIED attributes will be omitted.</p> 0251 * 0252 * @param uri The URI of the associated namespace for this element 0253 * @param localname The local part of the element name 0254 * @param qname The QName of this element 0255 * @param attrs The attributes attached to the element, if any. 0256 * @exception SAXException Any SAX exception, possibly 0257 * wrapping another exception. 0258 * @see #endElement 0259 * @see Attributes#Attributes 0260 */ 0261 virtual void startElement 0262 ( 0263 const XMLCh* const uri, 0264 const XMLCh* const localname, 0265 const XMLCh* const qname, 0266 const Attributes& attrs 0267 ) = 0; 0268 0269 /** 0270 * Receive notification of the start of an namespace prefix mapping. 0271 * 0272 * <p>By default, do nothing. Application writers may override this 0273 * method in a subclass to take specific actions at the start of 0274 * each namespace prefix mapping.</p> 0275 * 0276 * @param prefix The namespace prefix used 0277 * @param uri The namespace URI used. 0278 * @exception SAXException Any SAX exception, possibly 0279 * wrapping another exception. 0280 */ 0281 virtual void startPrefixMapping 0282 ( 0283 const XMLCh* const prefix, 0284 const XMLCh* const uri 0285 ) = 0 ; 0286 0287 /** 0288 * Receive notification of the end of an namespace prefix mapping. 0289 * 0290 * <p>By default, do nothing. Application writers may override this 0291 * method in a subclass to take specific actions at the end of 0292 * each namespace prefix mapping.</p> 0293 * 0294 * @param prefix The namespace prefix used 0295 * @exception SAXException Any SAX exception, possibly 0296 * wrapping another exception. 0297 */ 0298 virtual void endPrefixMapping 0299 ( 0300 const XMLCh* const prefix 0301 ) = 0 ; 0302 0303 /** 0304 * Receive notification of a skipped entity 0305 * 0306 * <p>The parser will invoke this method once for each entity 0307 * skipped. All processors may skip external entities, 0308 * depending on the values of the features:<br> 0309 * http://xml.org/sax/features/external-general-entities<br> 0310 * http://xml.org/sax/features/external-parameter-entities</p> 0311 * 0312 * <p>Note: Xerces (specifically) never skips any entities, regardless 0313 * of the above features. This function is never called in the 0314 * Xerces implementation of SAX2.</p> 0315 * 0316 * <p>Introduced with SAX2</p> 0317 * 0318 * @param name The name of the skipped entity. If it is a parameter entity, 0319 * the name will begin with %, and if it is the external DTD subset, 0320 * it will be the string [dtd]. 0321 * @exception SAXException Any SAX exception, possibly 0322 * wrapping another exception. 0323 */ 0324 virtual void skippedEntity 0325 ( 0326 const XMLCh* const name 0327 ) = 0 ; 0328 0329 //@} 0330 private : 0331 /* Unimplemented Constructors and operators */ 0332 /* Copy constructor */ 0333 ContentHandler(const ContentHandler&); 0334 /** Assignment operator */ 0335 ContentHandler& operator=(const ContentHandler&); 0336 }; 0337 0338 XERCES_CPP_NAMESPACE_END 0339 0340 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |