You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@locus.apache.org on 2000/11/30 19:22:46 UTC

cvs commit: xml-xerces/c/src/validators/DTD DTDValidator.cpp

andyh       00/11/30 10:22:45

  Modified:    c/src/framework XMLAttDef.cpp XMLAttDef.hpp
                        XMLElementDecl.hpp
               c/src/internal XMLScanner.cpp XMLScanner2.cpp
               c/src/validators/DTD DTDValidator.cpp
  Log:
  reuseValidator - fix bugs (spurious errors) that occured on reuse due to
  pools already containing some items.  Fixed by Tinny Ng.
  
  Revision  Changes    Path
  1.5       +3 -1      xml-xerces/c/src/framework/XMLAttDef.cpp
  
  Index: XMLAttDef.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLAttDef.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLAttDef.cpp	2000/07/25 22:33:28	1.4
  +++ XMLAttDef.cpp	2000/11/30 18:22:38	1.5
  @@ -55,7 +55,7 @@
    */
   
   /**
  - * $Id: XMLAttDef.cpp,v 1.4 2000/07/25 22:33:28 aruna1 Exp $
  + * $Id: XMLAttDef.cpp,v 1.5 2000/11/30 18:22:38 andyh Exp $
    */
   
   
  @@ -150,6 +150,7 @@
       , fProvided(false)
       , fType(type)
       , fValue(0)
  +    , fCreateReason(XMLAttDef::NoReason)
   {
   }
   
  @@ -164,6 +165,7 @@
       , fProvided(false)
       , fType(type)
       , fValue(0)
  +    , fCreateReason(XMLAttDef::NoReason)
   {
       try
       {
  
  
  
  1.7       +47 -0     xml-xerces/c/src/framework/XMLAttDef.hpp
  
  Index: XMLAttDef.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLAttDef.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLAttDef.hpp	2000/07/07 22:23:38	1.6
  +++ XMLAttDef.hpp	2000/11/30 18:22:38	1.7
  @@ -56,6 +56,10 @@
   
   /*
    * $Log: XMLAttDef.hpp,v $
  + * Revision 1.7  2000/11/30 18:22:38  andyh
  + * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
  + * pools already containing some items.  Fixed by Tinny Ng.
  + *
    * Revision 1.6  2000/07/07 22:23:38  jpolast
    * remove useless getKey() functions.
    *
  @@ -117,6 +121,11 @@
       //  DefAttTypes
       //      The modifiers that an attribute decl can have, which indicates
       //      whether instances of that attributes are required, implied, etc..
  +    //
  +    //  CreateReasons
  +    //      This type is used to store how an attribute declaration got into
  +    //      the elementdecl's attribute pool.
  +    //
       // -----------------------------------------------------------------------
   	enum AttTypes
       {
  @@ -150,6 +159,11 @@
           , DefAttTypes_Unknown = -1
   	};
   
  +    enum CreateReasons
  +    {
  +        NoReason
  +        , JustFaultIn
  +    };
   
       // -----------------------------------------------------------------------
       //  Public static data members
  @@ -300,6 +314,16 @@
         */
       const XMLCh* getValue() const;
   
  +    /** Get the create reason for this attribute
  +      *
  +      * This method returns an enumeration which indicates why this attribute
  +      * declaration exists.
  +      *
  +      * @return An enumerated value that indicates the reason why this attribute
  +      * was added to the attribute table.
  +      */
  +    CreateReasons getCreateReason() const;
  +
       //@}
   
   
  @@ -373,6 +397,13 @@
         */
       void setEnumeration(const XMLCh* const newValue);
   
  +    /** Update the create reason for this attribute type.
  +      *
  +      * This method will update the 'create reason' field for this attribute
  +      * decl object.
  +      */
  +    void setCreateReason(const CreateReasons newReason);
  +
       //@}
   
   protected :
  @@ -434,6 +465,11 @@
       //  fValue
       //      This is the value of the attribute, which is the default value
       //      given in the attribute declaration.
  +    //
  +    //  fCreateReason
  +    //      This flag tells us how this attribute got created.  Sometimes even
  +    //      the attribute was not declared for the element, we want to fault
  +    //      fault it into the pool to avoid lots of redundant errors.
       // -----------------------------------------------------------------------
       DefAttTypes     fDefaultType;
       XMLCh*          fEnumeration;
  @@ -441,6 +477,7 @@
       bool            fProvided;
       AttTypes        fType;
       XMLCh*          fValue;
  +    CreateReasons       fCreateReason;
   };
   
   
  @@ -478,7 +515,12 @@
       return fValue;
   }
   
  +inline XMLAttDef::CreateReasons XMLAttDef::getCreateReason() const
  +{
  +    return fCreateReason;
  +}
   
  +
   // ---------------------------------------------------------------------------
   //  XMLAttDef: Setter methods
   // ---------------------------------------------------------------------------
  @@ -512,6 +554,12 @@
   {
       delete [] fValue;
       fValue = XMLString::replicate(newValue);
  +}
  +
  +inline void
  +XMLAttDef::setCreateReason(const XMLAttDef::CreateReasons newReason)
  +{
  +    fCreateReason = newReason;
   }
   
   #endif
  
  
  
  1.7       +6 -0      xml-xerces/c/src/framework/XMLElementDecl.hpp
  
  Index: XMLElementDecl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/framework/XMLElementDecl.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XMLElementDecl.hpp	2000/05/11 23:11:32	1.6
  +++ XMLElementDecl.hpp	2000/11/30 18:22:38	1.7
  @@ -56,6 +56,10 @@
   
   /*
    * $Log: XMLElementDecl.hpp,v $
  + * Revision 1.7  2000/11/30 18:22:38  andyh
  + * reuseValidator - fix bugs (spurious errors) that occured on reuse due to
  + * pools already containing some items.  Fixed by Tinny Ng.
  + *
    * Revision 1.6  2000/05/11 23:11:32  andyh
    * Add missing validity checks for stand-alone documents, character range
    * and Well-formed parsed entities.  Changes contributed by Sean MacRoibeaird
  @@ -138,6 +142,7 @@
           , AttList
           , InContentModel
           , AsRootElem
  +        , JustFaultIn
       };
   
       enum LookupOpts
  
  
  
  1.24      +34 -1     xml-xerces/c/src/internal/XMLScanner.cpp
  
  Index: XMLScanner.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner.cpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- XMLScanner.cpp	2000/11/01 23:47:33	1.23
  +++ XMLScanner.cpp	2000/11/30 18:22:41	1.24
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner.cpp,v 1.23 2000/11/01 23:47:33 andyh Exp $
  + * $Id: XMLScanner.cpp,v 1.24 2000/11/30 18:22:41 andyh Exp $
    */
   
   
  @@ -2018,6 +2018,10 @@
           // If validating then emit an error
           if (fValidate)
           {
  +            // This is to tell the reuse Validator that this element was
  +            // faulted-in, was not an element in the validator pool originally
  +            elemDecl->setCreateReason(XMLElementDecl::JustFaultIn);
  +
               fValidator->emitError
               (
                   XMLValid::ElementNotDefined
  @@ -2202,6 +2206,11 @@
                   //
                   if (fValidate)
                   {
  +                   // This is to tell the reuse Validator that this attribute was
  +                   // faulted-in, was not an attribute in the attdef originally
  +                    if(!fReuseValidator)
  +                       attDef->setCreateReason(XMLAttDef::JustFaultIn);
  +
                       fValidator->emitError
                       (
                           XMLValid::AttNotDefinedForElement
  @@ -2210,6 +2219,26 @@
                       );
                   }
               }
  +            else
  +            {
  +               // If we are reusing validator and this attribute was faulted-in,
  +               // then emit an error
  +               if (fValidate)
  +               {
  +                  if (fReuseValidator && attDef->getCreateReason()==XMLAttDef::JustFaultIn)
  +                  {
  +                      //reset the CreateReason to avoid redundant error
  +                      attDef->setCreateReason(XMLAttDef::NoReason);
  +
  +                      fValidator->emitError
  +                      (
  +                          XMLValid::AttNotDefinedForElement
  +                          , fAttNameBuf.getRawBuffer()
  +                          , elemDecl->getFullName()
  +                      );
  +                   }
  +                }
  +            }
   
               //
               //  If its already provided, then there are more than one of
  @@ -2652,6 +2681,10 @@
           // If validating then emit an error
           if (fValidate)
           {
  +            // This is to tell the reuse Validator that this element was
  +            // faulted-in, was not an element in the validator pool originally
  +            elemDecl->setCreateReason(XMLElementDecl::JustFaultIn);
  +
               fValidator->emitError
               (
                   XMLValid::ElementNotDefined
  
  
  
  1.18      +33 -1     xml-xerces/c/src/internal/XMLScanner2.cpp
  
  Index: XMLScanner2.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner2.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLScanner2.cpp	2000/09/08 23:14:32	1.17
  +++ XMLScanner2.cpp	2000/11/30 18:22:42	1.18
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner2.cpp,v 1.17 2000/09/08 23:14:32 andyh Exp $
  + * $Id: XMLScanner2.cpp,v 1.18 2000/11/30 18:22:42 andyh Exp $
    */
   
   
  @@ -215,6 +215,11 @@
               {
                   if (fValidate && !isNSAttr)
                   {
  +                    // This is to tell the reuse Validator that this attribute was
  +                    // faulted-in, was not an attribute in the attdef originally
  +                    if(!fReuseValidator)
  +                       attDef->setCreateReason(XMLAttDef::JustFaultIn);
  +
                       XMLBuffer bufURI;
                       fValidator->getURIText(uriId, bufURI);
                       XMLBuffer bufMsg;
  @@ -230,6 +235,33 @@
                       );
                   }
               }
  +            else
  +            {
  +                // If we are reusing validator and this attribute was faulted-in,
  +                // then emit an error
  +                if (fValidate && !isNSAttr)
  +                {
  +                   if (fReuseValidator && attDef->getCreateReason()==XMLAttDef::JustFaultIn)
  +                   {
  +                      //reset the CreateReason to avoid redundant error
  +                      attDef->setCreateReason(XMLAttDef::NoReason);
  +
  +                      XMLBuffer bufURI;
  +                      fValidator->getURIText(uriId, bufURI);
  +                      XMLBuffer bufMsg;
  +                      bufMsg.append(chOpenCurly);
  +                      bufMsg.append(bufURI.getRawBuffer());
  +                      bufMsg.append(chCloseCurly);
  +                      bufMsg.append(suffPtr);
  +                      fValidator->emitError
  +                      (
  +                          XMLValid::AttNotDefinedForElement
  +                          , bufMsg.getRawBuffer()
  +                          , elemDecl.getFullName()
  +                      );
  +                   }
  +                }
  +             }
   
               // Mark this one as provided (even if it was faulted in)
               attDef->setProvided(true);
  
  
  
  1.11      +4 -1      xml-xerces/c/src/validators/DTD/DTDValidator.cpp
  
  Index: DTDValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/DTD/DTDValidator.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DTDValidator.cpp	2000/08/09 22:08:48	1.10
  +++ DTDValidator.cpp	2000/11/30 18:22:44	1.11
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: DTDValidator.cpp,v 1.10 2000/08/09 22:08:48 jpolast Exp $
  + * $Id: DTDValidator.cpp,v 1.11 2000/11/30 18:22:44 andyh Exp $
    */
   
   
  @@ -821,6 +821,9 @@
                   else
                   {
                       #if defined(XERCES_DEBUG)
  +                      if(reuseValidator && reason == XMLElementDecl::JustFaultIn){
  +                      }
  +                      else
                       ThrowXML(RuntimeException, XMLExcepts::DTD_UnknownCreateReason);
                       #endif
                   }