Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:53

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_XMLDOCUMENTHANDLER_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XMLDOCUMENTHANDLER_HPP
0024 
0025 #include <xercesc/util/XercesDefs.hpp>
0026 #include <xercesc/util/RefVectorOf.hpp>
0027 #include <xercesc/framework/XMLAttr.hpp>
0028 
0029 XERCES_CPP_NAMESPACE_BEGIN
0030 
0031 class XMLElementDecl;
0032 class XMLEntityDecl;
0033 
0034 /**
0035   * This abstract class provides the interface for the scanner to return
0036   * XML document information up to the parser as it scans through the
0037   * document.
0038   *
0039   * The interface is very similar to org.sax.DocumentHandler, but
0040   * has some extra methods required to get all the data out.
0041   */
0042 class XMLPARSER_EXPORT XMLDocumentHandler
0043 {
0044 public:
0045     // -----------------------------------------------------------------------
0046     //  Constructors are hidden, just the virtual destructor is exposed
0047     // -----------------------------------------------------------------------
0048     /** @name Destructor */
0049     //@{
0050     virtual ~XMLDocumentHandler()
0051     {
0052     }
0053     //@}
0054 
0055     /** @name The document handler interface */
0056     //@{
0057     /** Receive notification of character data.
0058       *
0059       * <p>The scanner will call this method to report each chunk of
0060       * character data. The scanner may return all contiguous character
0061       * data in a single chunk, or they may split it into several
0062       * chunks; however, all of the characters in any single event
0063       * will come from the same external entity, so that the Locator
0064       * provides useful information.</p>
0065       *
0066       * <p>The parser must not attempt to read from the array
0067       * outside of the specified range.</p>
0068       *
0069       * @param  chars           The content (characters) between markup from the XML
0070       *                         document.
0071       * @param  length          The number of characters to read from the array.
0072       * @param  cdataSection    Indicates that this data is inside a CDATA
0073       *                         section.
0074       * @see #ignorableWhitespace
0075       * @see Locator
0076       */
0077     virtual void docCharacters
0078     (
0079         const   XMLCh* const    chars
0080         , const XMLSize_t       length
0081         , const bool            cdataSection
0082     ) = 0;
0083 
0084     /** Receive notification of comments in the XML content being parsed.
0085       *
0086       * This scanner will call this method for any comments found in the
0087       * content of the document.
0088       *
0089       * @param comment The text of the comment.
0090       */
0091     virtual void docComment
0092     (
0093         const   XMLCh* const    comment
0094     ) = 0;
0095 
0096     /** Receive notification of PI's parsed in the XML content.
0097       *
0098       * The scanner will call this method for any PIs it finds within the
0099       * content of the document.
0100       *
0101       * @param  target  The name of the PI.
0102       * @param  data    The body of the PI. This may be an empty string since
0103       *                 the body is optional.
0104       */
0105     virtual void docPI
0106     (
0107         const   XMLCh* const    target
0108         , const XMLCh* const    data
0109     ) = 0;
0110 
0111     /** Receive notification after the scanner has parsed the end of the
0112       * document.
0113       *
0114       * The scanner will call this method when the current document has been
0115       * fully parsed. The handler may use this opportunity to do something with
0116       * the data, clean up temporary data, etc...
0117       */
0118     virtual void endDocument() = 0;
0119 
0120     /** Receive notification of the end of an element.
0121       *
0122       * This method is called when scanner encounters the end of element tag.
0123       * There will be a corresponding startElement() event for every
0124       * endElement() event, but not necessarily the other way around. For
0125       * empty tags, there is only a startElement() call.
0126       *
0127       * @param  elemDecl The name of the element whose end tag was just
0128       *                     parsed.
0129       * @param  uriId       The ID of the URI in the URI pool (only valid if
0130       *                     name spaces is enabled)
0131       * @param  isRoot      Indicates if this is the root element.
0132       * @param  prefixName  The string representing the prefix name
0133       */
0134     virtual void endElement
0135     (
0136         const   XMLElementDecl& elemDecl
0137         , const unsigned int    uriId
0138         , const bool            isRoot
0139         , const XMLCh* const    prefixName = 0
0140     ) = 0;
0141 
0142     /** Receive notification when a referenced entity's content ends
0143       *
0144       * This method is called when scanner encounters the end of an entity
0145       * reference.
0146       *
0147       * @param  entDecl  The name of the entity reference just scanned.
0148       */
0149     virtual void endEntityReference
0150     (
0151         const   XMLEntityDecl&  entDecl
0152     ) = 0;
0153 
0154     /** Receive notification of ignorable whitespace in element content.
0155       *
0156       * <p>Validating Parsers must use this method to report each chunk
0157       * of ignorable whitespace (see the W3C XML 1.0 recommendation,
0158       * section 2.10): non-validating parsers may also use this method
0159       * if they are capable of parsing and using content models.</p>
0160       *
0161       * <p>The scanner may return all contiguous whitespace in a single
0162       * chunk, or it may split it into several chunks; however, all of
0163       * the characters in any single event will come from the same
0164       * external entity, so that the Locator provides useful
0165       * information.</p>
0166       *
0167       * <p>The parser must not attempt to read from the array
0168       * outside of the specified range.</p>
0169       *
0170       * @param  chars       The whitespace characters from the XML document.
0171       * @param  length      The number of characters to read from the array.
0172       * @param  cdataSection Indicates that this data is inside a CDATA
0173       *                     section.
0174       * @see #docCharacters
0175       */
0176     virtual void ignorableWhitespace
0177     (
0178         const   XMLCh* const    chars
0179         , const XMLSize_t       length
0180         , const bool            cdataSection
0181     ) = 0;
0182 
0183     /** Reset the document handler's state, if required
0184       *
0185       * This method is used to give the registered document handler a
0186       * chance to reset itself. Its called by the scanner at the start of
0187       * every parse.
0188       */
0189     virtual void resetDocument() = 0;
0190 
0191     /** Receive notification of the start of a new document
0192       *
0193       * This method is the first callback called the scanner at the
0194       * start of every parse. This is before any content is parsed.
0195       */
0196     virtual void startDocument() = 0;
0197 
0198     /** Receive notification of a new start tag
0199       *
0200       * This method is called when scanner encounters the start of an element tag.
0201       * All elements must always have a startElement() tag. Empty tags will
0202       * only have the startElement() tag and no endElement() tag.
0203       *
0204       * @param  elemDecl The name of the element whose start tag was just
0205       *                     parsed.
0206       * @param  uriId       The ID of the URI in the URI pool (only valid if
0207       *                     name spaces is enabled)
0208       * @param  prefixName  The string representing the prefix name
0209       * @param  attrList    List of attributes in the element
0210       * @param  attrCount   Count of the attributes in the element
0211       * @param  isEmpty     Indicates if the element is empty, in which case
0212       *                     you should not expect an endElement() event.
0213       * @param  isRoot      Indicates if this is the root element.
0214       */
0215     virtual void startElement
0216     (
0217         const   XMLElementDecl&         elemDecl
0218         , const unsigned int            uriId
0219         , const XMLCh* const            prefixName
0220         , const RefVectorOf<XMLAttr>&   attrList
0221         , const XMLSize_t               attrCount
0222         , const bool                    isEmpty
0223         , const bool                    isRoot
0224     ) = 0;
0225 
0226     /** Receive notification when the scanner hits an entity reference.
0227       *
0228       * This is currently useful only to DOM parser configurations as SAX
0229       * does not provide any api to return this information.
0230       *
0231       * @param  entDecl  The name of the entity that was referenced.
0232       */
0233     virtual void startEntityReference(const XMLEntityDecl& entDecl) = 0;
0234 
0235     /** Receive notification of an XML declaration
0236       *
0237       * Currently neither DOM nor SAX provide API's to return back this
0238       * information.
0239       *
0240       * @param  versionStr      The value of the <code>version</code> pseudoattribute
0241       *                         of the XML decl.
0242       * @param  encodingStr     The value of the <code>encoding</code> pseudoattribute
0243       *                         of the XML decl.
0244       * @param  standaloneStr   The value of the <code>standalone</code>
0245       *                         pseudoattribute of the XML decl.
0246       * @param  autoEncodingStr The encoding string auto-detected by the
0247       *                         scanner. In absence of any 'encoding' attribute in the
0248       *                         XML decl, the XML standard specifies how a parser can
0249       *                         auto-detect. If there is no <code>encodingStr</code>
0250       *                         this is what will be used to try to decode the file.
0251       */
0252     virtual void XMLDecl
0253     (
0254         const   XMLCh* const    versionStr
0255         , const XMLCh* const    encodingStr
0256         , const XMLCh* const    standaloneStr
0257         , const XMLCh* const    autoEncodingStr
0258     ) = 0;
0259 
0260     //@}
0261 
0262 
0263 
0264 protected :
0265     // -----------------------------------------------------------------------
0266     //  Hidden Constructors
0267     // -----------------------------------------------------------------------
0268     XMLDocumentHandler()
0269     {
0270     }
0271 
0272 
0273 private:
0274     // -----------------------------------------------------------------------
0275     //  Unimplemented constructors and operators
0276     // -----------------------------------------------------------------------
0277     XMLDocumentHandler(const XMLDocumentHandler&);
0278     XMLDocumentHandler& operator=(const XMLDocumentHandler&);
0279 };
0280 
0281 XERCES_CPP_NAMESPACE_END
0282 
0283 #endif