Back to home page

EIC code displayed by LXR

 
 

    


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_DOCUMENTHANDLER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_DOCUMENTHANDLER_HPP
0024 
0025 #include <xercesc/util/XercesDefs.hpp>
0026 
0027 XERCES_CPP_NAMESPACE_BEGIN
0028 
0029 class AttributeList;
0030 class Locator;
0031 
0032 /**
0033   * Receive notification of general document events.
0034   *
0035   * <p>This is the main interface that most SAX 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 SAX 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 HandlerBase, which implements
0050   * the default functionality; parser writers can instantiate
0051   * HandlerBase 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 HandlerBase#HandlerBase
0058   */
0059 
0060 class SAX_EXPORT DocumentHandler
0061 {
0062 public:
0063     /** @name Constructors and Destructor */
0064     //@{
0065     /** Default constructor */
0066     DocumentHandler()
0067     {
0068     }
0069 
0070     /** Destructor */
0071     virtual ~DocumentHandler()
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     * <p>If the element name has a namespace prefix, the prefix will
0132     * still be attached to the name.</p>
0133     *
0134     * @param name The element type name
0135     * @exception SAXException Any SAX exception, possibly
0136     *            wrapping another exception.
0137     */
0138     virtual void endElement(const XMLCh* const name) = 0;
0139 
0140   /**
0141     * Receive notification of ignorable whitespace in element content.
0142     *
0143     * <p>Validating Parsers must use this method to report each chunk
0144     * of ignorable whitespace (see the W3C XML 1.0 recommendation,
0145     * section 2.10): non-validating parsers may also use this method
0146     * if they are capable of parsing and using content models.</p>
0147     *
0148     * <p>SAX parsers may return all contiguous whitespace in a single
0149     * chunk, or they may split it into several chunks; however, all of
0150     * the characters in any single event must come from the same
0151     * external entity, so that the Locator provides useful
0152     * information.</p>
0153     *
0154     * <p>The application must not attempt to read from the array
0155     * outside of the specified range.</p>
0156     *
0157     * @param chars The characters from the XML document.
0158     * @param length The number of characters to read from the array.
0159     * @exception SAXException Any SAX exception, possibly
0160     *            wrapping another exception.
0161     * @see #characters
0162     */
0163     virtual void ignorableWhitespace
0164     (
0165         const   XMLCh* const    chars
0166         , const XMLSize_t       length
0167     ) = 0;
0168 
0169   /**
0170     * Receive notification of a processing instruction.
0171     *
0172     * <p>The Parser will invoke this method once for each processing
0173     * instruction found: note that processing instructions may occur
0174     * before or after the main document element.</p>
0175     *
0176     * <p>A SAX parser should never report an XML declaration (XML 1.0,
0177     * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
0178     * using this method.</p>
0179     *
0180     * @param target The processing instruction target.
0181     * @param data The processing instruction data, or null if
0182     *        none was supplied.
0183     * @exception SAXException Any SAX exception, possibly
0184     *            wrapping another exception.
0185     */
0186     virtual void processingInstruction
0187     (
0188         const   XMLCh* const    target
0189         , const XMLCh* const    data
0190     ) = 0;
0191 
0192     /**
0193     * Reset the Document object on its reuse
0194     *
0195     * <p>This method helps in reseting the document implementation
0196     * defaults each time the document is begun.</p>
0197     *
0198     */
0199     virtual void resetDocument() = 0;
0200 
0201   /**
0202     * Receive an object for locating the origin of SAX document events.
0203     *
0204     * SAX parsers are strongly encouraged (though not absolutely
0205     * required) to supply a locator: if it does so, it must supply
0206     * the locator to the application by invoking this method before
0207     * invoking any of the other methods in the DocumentHandler
0208     * interface.
0209     *
0210     * The locator allows the application to determine the end
0211     * position of any document-related event, even if the parser is
0212     * not reporting an error.  Typically, the application will
0213     * use this information for reporting its own errors (such as
0214     * character content that does not match an application's
0215     * business rules). The information returned by the locator
0216     * is probably not sufficient for use with a search engine.
0217     *
0218     * Note that the locator will return correct information only
0219     * during the invocation of the events in this interface. The
0220     * application should not attempt to use it at any other time.
0221     *
0222     * @param locator An object that can return the location of
0223     *                any SAX document event. The object is only
0224     *                'on loan' to the client code and they are not
0225     *                to attempt to delete or modify it in any way!
0226     *
0227     * @see Locator#Locator
0228     */
0229     virtual void setDocumentLocator(const Locator* const locator) = 0;
0230 
0231   /**
0232     * Receive notification of the beginning of a document.
0233     *
0234     * <p>The SAX parser will invoke this method only once, before any
0235     * other methods in this interface or in DTDHandler (except for
0236     * setDocumentLocator).</p>
0237     *
0238     * @exception SAXException Any SAX exception, possibly
0239     *            wrapping another exception.
0240     */
0241     virtual void startDocument() = 0;
0242 
0243   /**
0244     * Receive notification of the beginning of an element.
0245     *
0246     * <p>The Parser will invoke this method at the beginning of every
0247     * element in the XML document; there will be a corresponding
0248     * endElement() event for every startElement() event (even when the
0249     * element is empty). All of the element's content will be
0250     * reported, in order, before the corresponding endElement()
0251     * event.</p>
0252     *
0253     * <p>If the element name has a namespace prefix, the prefix will
0254     * still be attached.  Note that the attribute list provided will
0255     * contain only attributes with explicit values (specified or
0256     * defaulted): \#IMPLIED attributes will be omitted.</p>
0257     *
0258     * @param name The element type name.
0259     * @param attrs The attributes attached to the element, if any.
0260     * @exception SAXException Any SAX exception, possibly
0261     *            wrapping another exception.
0262     * @see #endElement
0263     * @see AttributeList#AttributeList
0264     */
0265     virtual void startElement
0266     (
0267         const   XMLCh* const    name
0268         ,       AttributeList&  attrs
0269     ) = 0;
0270 
0271     //@}
0272 
0273 private :
0274     /* Unimplemented Constructors and operators */
0275     /* Copy constructor */
0276     DocumentHandler(const DocumentHandler&);
0277     /** Assignment operator */
0278     DocumentHandler& operator=(const DocumentHandler&);
0279 };
0280 
0281 XERCES_CPP_NAMESPACE_END
0282 
0283 #endif