You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2002/01/28 18:08:34 UTC

cvs commit: xml-xerces/c/src/sax2 DeclHandler.hpp DefaultHandler.hpp Makefile.in SAX2XMLReader.hpp

knoaman     02/01/28 09:08:34

  Modified:    c/src/sax2 DefaultHandler.hpp Makefile.in SAX2XMLReader.hpp
  Added:       c/src/sax2 DeclHandler.hpp
  Log:
  SAX2-ext's DeclHandler support.
  
  Revision  Changes    Path
  1.6       +121 -3    xml-xerces/c/src/sax2/DefaultHandler.hpp
  
  Index: DefaultHandler.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/sax2/DefaultHandler.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultHandler.hpp	13 Nov 2001 13:24:05 -0000	1.5
  +++ DefaultHandler.hpp	28 Jan 2002 17:08:33 -0000	1.6
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: DefaultHandler.hpp,v $
  + * Revision 1.6  2002/01/28 17:08:33  knoaman
  + * SAX2-ext's DeclHandler support.
  + *
    * Revision 1.5  2001/11/13 13:24:05  tng
    * Fix documentation for DefaultHandler.
    *
  @@ -82,6 +85,7 @@
   
   #include <sax2/ContentHandler.hpp>
   #include <sax2/LexicalHandler.hpp>
  +#include <sax2/DeclHandler.hpp>
   #include <sax/DTDHandler.hpp>
   #include <sax/EntityResolver.hpp>
   #include <sax/ErrorHandler.hpp>
  @@ -95,7 +99,7 @@
     *
     * <p>This class implements the default behaviour for SAX2
     * interfaces: EntityResolver, DTDHandler, ContentHandler,
  -  * ErrorHandler, and LexicalHandler.</p>
  +  * ErrorHandler, LexicalHandler, and DeclHandler.</p>
     *
     * <p>Application writers can extend this class when they need to
     * implement only part of an interface; parser writers can
  @@ -109,6 +113,7 @@
     * @see ContentHandler#ContentHandler
     * @see ErrorHandler#ErrorHandler
     * @see LexicalHandler#LexicalHandler
  +  * @see DeclHandler#DeclHandler
     */
   
   class SAX2_EXPORT DefaultHandler :
  @@ -116,8 +121,9 @@
       public EntityResolver,
   	public DTDHandler,
   	public ContentHandler,
  -   public ErrorHandler,
  -   public LexicalHandler
  +    public ErrorHandler,
  +    public LexicalHandler,
  +    public DeclHandler
   {
   public:
     /** @name Default handlers for the DocumentHandler interface */
  @@ -594,6 +600,94 @@
       virtual void startEntity (const XMLCh* const name);
   
       //@}
  +
  +    /** @name Default implementation of DeclHandler interface. */
  +
  +    //@{
  +
  +   /**
  +    * Report an element type declaration.
  +    *
  +    * <p>The content model will consist of the string "EMPTY", the string
  +    * "ANY", or a parenthesised group, optionally followed by an occurrence
  +    * indicator. The model will be normalized so that all parameter entities
  +    * are fully resolved and all whitespace is removed,and will include the
  +    * enclosing parentheses. Other normalization (such as removing redundant
  +    * parentheses or simplifying occurrence indicators) is at the discretion
  +    * of the parser.</p>
  +    *
  +    * @param name The element type name.
  +    * @param model The content model as a normalized string.
  +    * @exception SAXException Any SAX exception, possibly
  +    *            wrapping another exception.
  +    */
  +    virtual void elementDecl
  +    (
  +        const   XMLCh* const    name
  +        , const XMLCh* const    model
  +    );
  +
  +   /**
  +    * Report an attribute type declaration.
  +    *
  +    * <p>Only the effective (first) declaration for an attribute will
  +    * be reported.</p>
  +    *
  +    * @param eName The name of the associated element.
  +    * @param aName The name of the attribute.
  +    * @param type A string representing the attribute type.
  +    * @param mode A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
  +    * @param value A string representing the attribute's default value, or null if there is none. 
  +    * @exception SAXException Any SAX exception, possibly
  +    *            wrapping another exception.
  +    */
  +    virtual void attributeDecl
  +    (
  +        const   XMLCh* const    eName
  +        , const XMLCh* const    aName
  +        , const XMLCh* const    type
  +        , const XMLCh* const    mode
  +        , const XMLCh* const    value
  +    );
  +
  +   /**
  +    * Report an internal entity declaration.
  +    *
  +    * <p>Only the effective (first) declaration for each entity will be 
  +    * reported. All parameter entities in the value will be expanded, but
  +    * general entities will not.</p>
  +    *
  +    * @param name The name of the entity. If it is a parameter entity, the name will begin with '%'.
  +    * @param value The replacement text of the entity.
  +    * @exception SAXException Any SAX exception, possibly
  +    *            wrapping another exception.
  +    */
  +    virtual void internalEntityDecl
  +    (
  +        const   XMLCh* const    name
  +        , const XMLCh* const    value
  +    );
  +
  +   /**
  +    * Report a parsed external entity declaration.
  +    *
  +    * <p>Only the effective (first) declaration for each entity will
  +    * be reported.</p>
  +    *
  +    * @param name The name of the entity. If it is a parameter entity, the name will begin with '%'.
  +    * @param publicId The The declared public identifier of the entity, or null if none was declared.
  +    * @param systemId The declared system identifier of the entity.
  +    * @exception SAXException Any SAX exception, possibly
  +    *            wrapping another exception.
  +    */
  +    virtual void externalEntityDecl
  +    (
  +        const   XMLCh* const    name
  +        , const XMLCh* const    publicId
  +        , const XMLCh* const    systemId
  +    );
  +
  +    //@}
   };
   
   
  @@ -731,6 +825,30 @@
   }
   
   inline void DefaultHandler::startEntity (const XMLCh* const name)
  +{
  +}
  +
  +inline void DefaultHandler::attributeDecl(const XMLCh* const,
  +                                          const XMLCh* const,
  +                                          const XMLCh* const,
  +                                          const XMLCh* const,
  +                                          const XMLCh* const)
  +{
  +}
  +
  +inline void DefaultHandler::elementDecl(const XMLCh* const,
  +                                        const XMLCh* const)
  +{
  +}
  +
  +inline void DefaultHandler::externalEntityDecl(const XMLCh* const,
  +                                               const XMLCh* const,
  +                                               const XMLCh* const)
  +{
  +}
  +
  +inline void DefaultHandler::internalEntityDecl(const XMLCh* const,
  +                                               const XMLCh* const)
   {
   }
   
  
  
  
  1.6       +2 -1      xml-xerces/c/src/sax2/Makefile.in
  
  Index: Makefile.in
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/sax2/Makefile.in,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Makefile.in	6 Jul 2001 17:11:58 -0000	1.5
  +++ Makefile.in	28 Jan 2002 17:08:33 -0000	1.6
  @@ -54,7 +54,7 @@
   # <http://www.apache.org/>.
   #
   #
  -# $Id: Makefile.in,v 1.5 2001/07/06 17:11:58 tng Exp $
  +# $Id: Makefile.in,v 1.6 2002/01/28 17:08:33 knoaman Exp $
   #
   
   PLATFORM = @platform@
  @@ -81,6 +81,7 @@
   	ContentHandler.hpp \
   	DefaultHandler.hpp \
   	LexicalHandler.hpp \
  +        DeclHandler.hpp \
   	SAX2XMLReader.hpp \
   	XMLReaderFactory.hpp
   
  
  
  
  1.17      +29 -0     xml-xerces/c/src/sax2/SAX2XMLReader.hpp
  
  Index: SAX2XMLReader.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/sax2/SAX2XMLReader.hpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- SAX2XMLReader.hpp	18 Jan 2002 16:31:26 -0000	1.16
  +++ SAX2XMLReader.hpp	28 Jan 2002 17:08:33 -0000	1.17
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SAX2XMLReader.hpp,v $
  + * Revision 1.17  2002/01/28 17:08:33  knoaman
  + * SAX2-ext's DeclHandler support.
  + *
    * Revision 1.16  2002/01/18 16:31:26  tng
    * Break program.xml which takes too long to load, into program-sax.xml, program-sax2.xml, program-dom.xml, program-idom.xml.
    *
  @@ -135,6 +138,7 @@
   class ErrorHandler;
   class InputSource;
   class LexicalHandler;
  +class DeclHandler;
   class XMLDocumentHandler;
   
   class SAX2_EXPORT SAX2XMLReader
  @@ -216,6 +220,13 @@
         */
       virtual LexicalHandler* getLexicalHandler() const = 0 ;
   
  +    /**
  +      * This method returns the installed declaration handler.
  +      *
  +      * @return A pointer to the installed declaration handler object.
  +      */
  +    virtual DeclHandler* getDeclarationHandler() const = 0 ;
  +
   	/**
        * Query the current state of any feature in a SAX2 XMLReader.
   	  *
  @@ -437,6 +448,24 @@
       * @see HandlerBase#HandlerBase
       */
       virtual void setLexicalHandler(LexicalHandler* const handler) = 0;
  +
  +   /**
  +    * Allow an application to register a declaration event handler.
  +    *
  +    * If the application does not register a declaration handler,
  +    * all events reported by the SAX parser will be silently
  +    * ignored. (this is the default behaviour implemented by DefaultHandler).
  +    *
  +    * Applications may register a new or different handler in the
  +    * middle of a parse, and the SAX parser must begin using the new
  +    * handler immediately.
  +    *
  +    * @param handler The DTD declaration handler.
  +    * @see DeclHandler#DeclHandler
  +    * @see SAXException#SAXException
  +    * @see DefaultHandler#DefaultHandler
  +    */
  +    virtual void setDeclarationHandler(DeclHandler* const handler) = 0;
   
       /**
         * This method allows users to set the parser's behaviour when it
  
  
  
  1.1                  xml-xerces/c/src/sax2/DeclHandler.hpp
  
  Index: DeclHandler.hpp
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   * 
   * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
   * reserved.
   * 
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   * 
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   * 
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   * 
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache\@apache.org.
   * 
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   * 
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   * 
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation, and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.ibm.com .  For more information
   * on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /*
   * $Log: DeclHandler.hpp,v $
   * Revision 1.1  2002/01/28 17:08:33  knoaman
   * SAX2-ext's DeclHandler support.
   *
   */
  
  
  #ifndef DECLHANDLER_HPP
  #define DECLHANDLER_HPP
  
  #include <util/XercesDefs.hpp>
  
  
  /**
    * Receive notification of DTD declaration events.
    *
    * <p>This is an optional extension handler for SAX2 to provide more
    * complete information about DTD declarations in an XML document.
    * XML readers are not required to recognize this handler, and it is not
    * part of core-only SAX2 distributions.</p>
    *
    * <p>Note that data-related DTD declarations (unparsed entities and
    * notations) are already reported through the DTDHandler interface.</p>
    *
    * <p>If you are using the declaration handler together with a lexical
    * handler, all of the events will occur between the startDTD and the endDTD
    * events.</p>
    *
    * @see SAX2XMLReader#setLexicalHandler
    * @see SAX2XMLReader#setDeclarationHandler
    */
  
  class SAX2_EXPORT DeclHandler
  {
  public:
      /** @name Constructors and Destructor */
      //@{
      /** Default constructor */
      DeclHandler()
      {
      }
  
      /** Destructor */
      virtual ~DeclHandler()
      {
      }
      //@}
  
      /** @name The virtual declaration handler interface */
      
      //@{
     /**
      * Report an element type declaration.
      *
      * <p>The content model will consist of the string "EMPTY", the string
      * "ANY", or a parenthesised group, optionally followed by an occurrence
      * indicator. The model will be normalized so that all parameter entities
      * are fully resolved and all whitespace is removed,and will include the
      * enclosing parentheses. Other normalization (such as removing redundant
      * parentheses or simplifying occurrence indicators) is at the discretion
      * of the parser.</p>
      *
      * @param name The element type name.
      * @param model The content model as a normalized string.
      * @exception SAXException Any SAX exception, possibly
      *            wrapping another exception.
      */
      virtual void elementDecl
      (
          const   XMLCh* const    name
          , const XMLCh* const    model
      ) = 0;
  
     /**
      * Report an attribute type declaration.
      *
      * <p>The Parser will call this method to report each occurence of
      * a comment in the XML document.</p>
      *
      * <p>The application must not attempt to read from the array
      * outside of the specified range.</p>
      *
      * @param eName The name of the associated element.
      * @param aName The name of the attribute.
      * @param type A string representing the attribute type.
      * @param mode A string representing the attribute defaulting mode ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if none of these applies.
      * @param value A string representing the attribute's default value, or null if there is none. 
      * @exception SAXException Any SAX exception, possibly
      *            wrapping another exception.
      */
      virtual void attributeDecl
      (
          const   XMLCh* const    eName
          , const XMLCh* const    aName
          , const XMLCh* const    type
          , const XMLCh* const    mode
          , const XMLCh* const    value
      ) = 0;
  
     /**
      * Report an internal entity declaration.
      *
      * <p>Only the effective (first) declaration for each entity will be 
      * reported. All parameter entities in the value will be expanded, but
      * general entities will not.</p>
      *
      * @param name The name of the entity. If it is a parameter entity, the name will begin with '%'.
      * @param value The replacement text of the entity.
      * @exception SAXException Any SAX exception, possibly
      *            wrapping another exception.
      */
      virtual void internalEntityDecl
      (
          const   XMLCh* const    name
          , const XMLCh* const    value
      ) = 0;
  
     /**
      * Report a parsed external entity declaration.
      *
      * <p>Only the effective (first) declaration for each entity will
      * be reported.</p>
      *
      * @param name The name of the entity. If it is a parameter entity, the name will begin with '%'.
      * @param publicId The The declared public identifier of the entity, or null if none was declared.
      * @param systemId The declared system identifier of the entity.
      * @exception SAXException Any SAX exception, possibly
      *            wrapping another exception.
      */
      virtual void externalEntityDecl
      (
          const   XMLCh* const    name
          , const XMLCh* const    publicId
          , const XMLCh* const    systemId
      ) = 0;
  
      //@}
  private :
      /* Unimplemented Constructors and operators */
      /* Copy constructor */
      DeclHandler(const DeclHandler&);
      /** Assignment operator */
      void operator=(const DeclHandler&);
  };
  
  #endif
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org