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 2001/06/07 21:08:40 UTC

cvs commit: xml-xerces/c/src/internal XMLScanner.cpp XMLScanner2.cpp

knoaman     01/06/07 12:08:39

  Modified:    c/src/internal XMLScanner.cpp XMLScanner2.cpp
  Log:
  Fix in validator reuse for 'xsi:nill' and faulted in attributes.
  
  Revision  Changes    Path
  1.45      +16 -22    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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- XMLScanner.cpp	2001/06/04 20:59:29	1.44
  +++ XMLScanner.cpp	2001/06/07 19:08:33	1.45
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner.cpp,v 1.44 2001/06/04 20:59:29 jberry Exp $
  + * $Id: XMLScanner.cpp,v 1.45 2001/06/07 19:08:33 knoaman Exp $
    */
   
   
  @@ -2344,10 +2344,9 @@
                   //
                   if (fValidate)
                   {
  -                   // This is to tell the reuse Validator that this attribute was
  -                   // faulted-in, was not an attribute in the attdef originally
  -                    if(!fReuseGrammar)
  -                       attDef->setCreateReason(XMLAttDef::JustFaultIn);
  +                    // This is to tell the Validator that this attribute was
  +                    // faulted-in, was not an attribute in the attdef originally
  +                    attDef->setCreateReason(XMLAttDef::JustFaultIn);
   
                       fValidator->emitError
                       (
  @@ -2359,22 +2358,17 @@
               }
               else
               {
  -               // If we are reusing validator and this attribute was faulted-in,
  -               // then emit an error
  -               if (fValidate)
  -               {
  -                  if (fReuseGrammar && attDef->getCreateReason()==XMLAttDef::JustFaultIn)
  -                  {
  -                      //reset the CreateReason to avoid redundant error
  -                      attDef->setCreateReason(XMLAttDef::NoReason);
  -
  -                      fValidator->emitError
  -                      (
  -                          XMLValid::AttNotDefinedForElement
  -                          , fAttNameBuf.getRawBuffer()
  -                          , elemDecl->getFullName()
  -                      );
  -                   }
  +                // If this attribute was faulted-in and first occurence,
  +                // then emit an error
  +                if (fValidate && attDef->getCreateReason() == XMLAttDef::JustFaultIn
  +                    && !attDef->getProvided())
  +                {
  +                    fValidator->emitError
  +                    (
  +                        XMLValid::AttNotDefinedForElement
  +                        , fAttNameBuf.getRawBuffer()
  +                        , elemDecl->getFullName()
  +                    );
                   }
               }
   
  @@ -2447,7 +2441,7 @@
               //  errors, but we just keep going. We only need to do this if
               //  we are validating.
               //
  -            if (!wasAdded)
  +            if (!wasAdded && attDef->getCreateReason() != XMLAttDef::JustFaultIn)
               {
                   // Let the validator pass judgement on the attribute value
                   if (fValidate)
  
  
  
  1.34      +55 -59    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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XMLScanner2.cpp	2001/06/04 20:59:29	1.33
  +++ XMLScanner2.cpp	2001/06/07 19:08:35	1.34
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner2.cpp,v 1.33 2001/06/04 20:59:29 jberry Exp $
  + * $Id: XMLScanner2.cpp,v 1.34 2001/06/07 19:08:35 knoaman Exp $
    */
   
   
  @@ -243,10 +243,9 @@
               {
                   if (fValidate && !isNSAttr)
                   {
  -                    // This is to tell the reuse Validator that this attribute was
  +                    // This is to tell the Validator that this attribute was
                       // faulted-in, was not an attribute in the attdef originally
  -                    if(!fReuseGrammar)
  -                       attDef->setCreateReason(XMLAttDef::JustFaultIn);
  +                    attDef->setCreateReason(XMLAttDef::JustFaultIn);
   
                       XMLBuffer bufURI;
                       getURIText(uriId, bufURI);
  @@ -266,35 +265,47 @@
               }
               else
               {
  -                // If we are reusing validator and this attribute was faulted-in,
  +                // If this attribute was faulted-in and first occurence,
                   // then emit an error
  -                if (fValidate && !isNSAttr)
  +                if (fValidate && !isNSAttr
  +                    && attDef->getCreateReason() == XMLAttDef::JustFaultIn
  +                    && !attDef->getProvided())
                   {
  -                   if (fReuseGrammar && attDef->getCreateReason()==XMLAttDef::JustFaultIn)
  -                   {
  -                      //reset the CreateReason to avoid redundant error
  -                      attDef->setCreateReason(XMLAttDef::NoReason);
  -
  -                      XMLBuffer bufURI;
  -                      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()
  -                      );
  -                   }
  +                    XMLBuffer bufURI;
  +                    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);
  +            //
  +            //  If its already provided, then there are more than one of
  +            //  this attribute in this start tag, so emit an error.
  +            //
  +            if (attDef->getProvided())
  +            {
  +                emitError
  +                (
  +                    XMLErrs::AttrAlreadyUsedInSTag
  +                    , attDef->getFullName()
  +                    , elemDecl.getFullName()
  +                );
  +            }
  +             else
  +            {
  +                // Mark this one as already seen
  +                attDef->setProvided(true);
  +            }
   
               //
               //  Now normalize the raw value since we have the attribute type. We
  @@ -312,7 +323,7 @@
               //
               //  If we found an attdef for this one, then lets validate it.
               //
  -            if (!wasAdded)
  +            if (!wasAdded && attDef->getCreateReason() != XMLAttDef::JustFaultIn)
               {
                   if (fValidate)
                   {
  @@ -335,24 +346,6 @@
   
               // Save the type for later use
               attType = attDef->getType();
  -
  -            // Make sure it's not a dup of anything so far
  -            for (unsigned int inner = 0; inner < retCount; inner++)
  -            {
  -                // If they have the same URI, then compare names
  -                if (uriId == toFill.elementAt(inner)->getURIId())
  -                {
  -                    if (!XMLString::compareString(suffPtr, toFill.elementAt(inner)->getName()))
  -                    {
  -                        emitError
  -                        (
  -                            XMLErrs::AttrAlreadyUsedInSTag
  -                            , attDef->getFullName()
  -                            , elemDecl.getFullName()
  -                        );
  -                    }
  -                }
  -            }
           }
            else
           {
  @@ -1106,7 +1099,7 @@
       }
   
       // walk through the list again to deal with "xsi:...."
  -    if (fDoSchema && fSeeXsi && !fReuseGrammar)
  +    if (fDoSchema && fSeeXsi)
       {
           for (index = 0; index < attCount; index++)
           {
  @@ -1121,19 +1114,22 @@
   
               // if schema URI has been seen, scan for the schema location and uri
               // and resolve the schema grammar; or scan for schema type
  -
               if (resolvePrefix(prefPtr, ElemStack::Mode_Attribute) == fSchemaNamespaceId) {
  -                if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_SCHEMALOCACTION))
  -                    parseSchemaLocation(valuePtr);
  -                else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCACTION))
  -                    resolveSchemaGrammar(valuePtr, XMLUni::fgZeroLenString);
  -                else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_TYPE))
  -                    fXsiType.set(valuePtr);
  -                else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgATT_NILL)) {
  -                    if (fValidator) {
  -                        if (!XMLString::compareString(valuePtr, SchemaSymbols::fgATTVAL_TRUE))
  +
  +                if (!fReuseGrammar) {
  +                    if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_SCHEMALOCACTION))
  +                        parseSchemaLocation(valuePtr);
  +                    else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_NONAMESPACESCHEMALOCACTION))
  +                        resolveSchemaGrammar(valuePtr, XMLUni::fgZeroLenString);
  +                }
  +
  +                if (!XMLString::compareString(suffPtr, SchemaSymbols::fgXSI_TYPE)) {
  +                        fXsiType.set(valuePtr);
  +                }
  +                else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgATT_NILL)
  +                         && fValidator
  +                         && !XMLString::compareString(valuePtr, SchemaSymbols::fgATTVAL_TRUE)) {
                               ((SchemaValidator*)fValidator)->setNillable(true);
  -                    }
                   }
               }
           }
  
  
  

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