You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2001/05/11 17:17:57 UTC

cvs commit: xml-xerces/c/src/validators/schema SchemaSymbols.cpp SchemaSymbols.hpp SchemaValidator.cpp SchemaValidator.hpp

tng         01/05/11 08:17:56

  Modified:    c/src/internal XMLScanner.cpp XMLScanner.hpp XMLScanner2.cpp
               c/src/validators/schema SchemaSymbols.cpp SchemaSymbols.hpp
                        SchemaValidator.cpp SchemaValidator.hpp
  Log:
  Schema: Nillable fixes.
  
  Revision  Changes    Path
  1.39      +11 -5     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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- XMLScanner.cpp	2001/05/11 13:26:17	1.38
  +++ XMLScanner.cpp	2001/05/11 15:17:24	1.39
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner.cpp,v 1.38 2001/05/11 13:26:17 tng Exp $
  + * $Id: XMLScanner.cpp,v 1.39 2001/05/11 15:17:24 tng Exp $
    */
   
   
  @@ -87,6 +87,7 @@
   #include <internal/EndOfEntityException.hpp>
   #include <validators/DTD/DocTypeHandler.hpp>
   #include <validators/DTD/DTDScanner.hpp>
  +#include <validators/schema/SchemaSymbols.hpp>
   
   
   
  @@ -174,10 +175,12 @@
       , fValidatorFromUser(false)
       , fValScheme(Val_Never)
       , fDoSchema(false)
  +    , fSeeXsi(false)
       , fEmptyNamespaceId(0)
       , fUnknownNamespaceId(0)
       , fXMLNamespaceId(0)
       , fXMLNSNamespaceId(0)
  +    , fSchemaNamespaceId(0)
       , fGrammarResolver(0)
       , fGrammar(0)
       , fEntityDeclPool(0)
  @@ -219,10 +222,12 @@
       , fValidatorFromUser(false)
       , fValScheme(Val_Never)
       , fDoSchema(false)
  +    , fSeeXsi(false)
       , fEmptyNamespaceId(0)
       , fUnknownNamespaceId(0)
       , fXMLNamespaceId(0)
       , fXMLNSNamespaceId(0)
  +    , fSchemaNamespaceId(0)
       , fGrammarResolver(0)
       , fGrammar(0)
       , fEntityDeclPool(0)
  @@ -902,6 +907,7 @@
       fUnknownNamespaceId = fURIStringPool->addOrFind(XMLUni::fgUnknownURIName);
       fXMLNamespaceId     = fURIStringPool->addOrFind(XMLUni::fgXMLURIName);
       fXMLNSNamespaceId   = fURIStringPool->addOrFind(XMLUni::fgXMLNSURIName);
  +    fSchemaNamespaceId  = fURIStringPool->addOrFind(SchemaSymbols::fgURI_XSI);
   }
   
   // ---------------------------------------------------------------------------
  @@ -2908,10 +2914,6 @@
           }
       }
   
  -    //  Validate the element
  -    if (fValidate)
  -        fValidator->validateElement(elemDecl);
  -
       //
       //  Now we can update the element stack to set the current element
       //  decl. We expanded the stack above, but couldn't store the element
  @@ -2959,6 +2961,10 @@
       //  explictly provided attrs above.
       //
       attCount = buildAttList(*fRawAttrList, attCount, *elemDecl, *fAttrList);
  +
  +    //  Validate the element
  +    if (fValidate)
  +        fValidator->validateElement(elemDecl);
   
       //
       //  If empty, validate content right now if we are validating and then
  
  
  
  1.18      +11 -0     xml-xerces/c/src/internal/XMLScanner.hpp
  
  Index: XMLScanner.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/internal/XMLScanner.hpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- XMLScanner.hpp	2001/05/11 13:26:17	1.17
  +++ XMLScanner.hpp	2001/05/11 15:17:28	1.18
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: XMLScanner.hpp,v $
  + * Revision 1.18  2001/05/11 15:17:28  tng
  + * Schema: Nillable fixes.
  + *
    * Revision 1.17  2001/05/11 13:26:17  tng
    * Copyright update.
    *
  @@ -701,6 +704,9 @@
       //      This flag indicates whether the client code wants Schema to
       //      be processed or not.
       //
  +    //  fSeeXsi
  +    //      This flag indicates a schema has been seen.
  +    //
       //  fAttName
       //  fAttValue
       //  fCDataBuf
  @@ -730,6 +736,9 @@
       //      defined but the latter is not, so we just provide one for debug
       //      purposes.
       //
  +    //  fSchemaNamespaceId
  +    //      This is the id of the schema namespace URI.
  +    //
       //  fGrammarResolver
       //      Grammar Pool that stores all the Grammar
       //
  @@ -772,6 +781,7 @@
       bool                        fValidatorFromUser;
       ValSchemes                  fValScheme;
       bool                        fDoSchema;
  +    bool                        fSeeXsi;
   
       XMLBuffer                   fAttNameBuf;
       XMLBuffer                   fAttValueBuf;
  @@ -785,6 +795,7 @@
       unsigned int                fUnknownNamespaceId;
       unsigned int                fXMLNamespaceId;
       unsigned int                fXMLNSNamespaceId;
  +    unsigned int                fSchemaNamespaceId;
   
       GrammarResolver*            fGrammarResolver;
       Grammar*                    fGrammar;
  
  
  
  1.30      +6 -13     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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- XMLScanner2.cpp	2001/05/11 13:26:18	1.29
  +++ XMLScanner2.cpp	2001/05/11 15:17:29	1.30
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: XMLScanner2.cpp,v 1.29 2001/05/11 13:26:18 tng Exp $
  + * $Id: XMLScanner2.cpp,v 1.30 2001/05/11 15:17:29 tng Exp $
    */
   
   
  @@ -1071,13 +1071,6 @@
   
   void XMLScanner::scanRawAttrListforNameSpaces(const RefVectorOf<KVStringPair>* theRawAttrList, int attCount) {
   
  -    //  Indicate if the schema URI (e.g. "http://www.w3.org/2000/10/XMLSchema-instance")
  -    //  has been seen
  -    bool seeXsi = false;
  -
  -    //  Schema prefix xxx (e.g. xmlns:xxx="http://www.w3.org/2000/10/XMLSchema-instance")
  -    XMLBuffer fXsiPrefix;
  -
       //  Schema Xsi Type yyyy (e.g. xsi:type="yyyyy")
       XMLBuffer fXsiType;
   
  @@ -1110,14 +1103,13 @@
   
               // if the schema URI is seen in the the valuePtr, set the boolean seeXsi
               if (!XMLString::compareString(valuePtr, SchemaSymbols::fgURI_XSI)) {
  -                fXsiPrefix.set(suffPtr);
  -                seeXsi = true;
  +                fSeeXsi = true;
               }
           }
       }
   
       // walk through the list again to deal with "xsi:...."
  -    if (fDoSchema && seeXsi && !fReuseGrammar)
  +    if (fDoSchema && fSeeXsi && !fReuseGrammar)
       {
           for (index = 0; index < attCount; index++)
           {
  @@ -1132,14 +1124,15 @@
   
               // if schema URI has been seen, scan for the schema location and uri
               // and resolve the schema grammar; or scan for schema type
  -            if (!XMLString::compareString(prefPtr, fXsiPrefix.getRawBuffer())) {
  +
  +            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_NILLABLE)) {
  +                else if (!XMLString::compareString(suffPtr, SchemaSymbols::fgATT_NILL)) {
                       if (fValidator) {
                           if (!XMLString::compareString(valuePtr, SchemaSymbols::fgATTVAL_TRUE))
                               ((SchemaValidator*)fValidator)->setNillable(true);
  
  
  
  1.5       +11 -3     xml-xerces/c/src/validators/schema/SchemaSymbols.cpp
  
  Index: SchemaSymbols.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaSymbols.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SchemaSymbols.cpp	2001/05/11 13:27:37	1.4
  +++ SchemaSymbols.cpp	2001/05/11 15:17:43	1.5
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaSymbols.cpp,v $
  + * Revision 1.5  2001/05/11 15:17:43  tng
  + * Schema: Nillable fixes.
  + *
    * Revision 1.4  2001/05/11 13:27:37  tng
    * Copyright update.
    *
  @@ -307,10 +310,10 @@
       chLatin_p, chLatin_e, chLatin_r, chLatin_i, chLatin_o, chLatin_d, chNull
   };
   
  -const XMLCh SchemaSymbols::fgELT_PRECISION[] =
  +const XMLCh SchemaSymbols::fgELT_TOTALDIGITS[] =
   {
  -    chLatin_p, chLatin_r, chLatin_e, chLatin_c, chLatin_i, chLatin_s,
  -    chLatin_i, chLatin_o, chLatin_n,  chNull
  +    chLatin_t, chLatin_o, chLatin_t, chLatin_a, chLatin_l, chLatin_D,
  +    chLatin_i, chLatin_g, chLatin_i, chLatin_t, chLatin_s, chNull
   };
   
   const XMLCh SchemaSymbols::fgELT_FRACTIONDIGITS[] =
  @@ -496,6 +499,11 @@
   {
       chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chLatin_p,
       chLatin_a, chLatin_c, chLatin_e, chNull
  +};
  +
  +const XMLCh SchemaSymbols::fgATT_NILL[] =
  +{
  +    chLatin_n, chLatin_i, chLatin_l, chNull
   };
   
   const XMLCh SchemaSymbols::fgATT_NILLABLE[] =
  
  
  
  1.6       +3 -2      xml-xerces/c/src/validators/schema/SchemaSymbols.hpp
  
  Index: SchemaSymbols.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaSymbols.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SchemaSymbols.hpp	2001/05/11 13:27:37	1.5
  +++ SchemaSymbols.hpp	2001/05/11 15:17:44	1.6
  @@ -55,7 +55,7 @@
    */
   
   /*
  - * $Id: SchemaSymbols.hpp,v 1.5 2001/05/11 13:27:37 tng Exp $
  + * $Id: SchemaSymbols.hpp,v 1.6 2001/05/11 15:17:44 tng Exp $
    */
   
   #if !defined(SCHEMASYMBOLS_HPP)
  @@ -110,7 +110,7 @@
       static const XMLCh fgELT_NOTATION[];
       static const XMLCh fgELT_PATTERN[];
       static const XMLCh fgELT_PERIOD[];
  -    static const XMLCh fgELT_PRECISION[];
  +    static const XMLCh fgELT_TOTALDIGITS[];
       static const XMLCh fgELT_FRACTIONDIGITS[];
       static const XMLCh fgELT_SCHEMA[];
       static const XMLCh fgELT_SELECTOR[];
  @@ -143,6 +143,7 @@
       static const XMLCh fgATT_MINOCCURS[];
       static const XMLCh fgATT_NAME[];
       static const XMLCh fgATT_NAMESPACE[];
  +    static const XMLCh fgATT_NILL[];
       static const XMLCh fgATT_NILLABLE[];
       static const XMLCh fgATT_PROCESSCONTENTS[];
       static const XMLCh fgATT_REF[];
  
  
  
  1.7       +41 -24    xml-xerces/c/src/validators/schema/SchemaValidator.cpp
  
  Index: SchemaValidator.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaValidator.cpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SchemaValidator.cpp	2001/05/11 13:27:37	1.6
  +++ SchemaValidator.cpp	2001/05/11 15:17:46	1.7
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.cpp,v $
  + * Revision 1.7  2001/05/11 15:17:46  tng
  + * Schema: Nillable fixes.
  + *
    * Revision 1.6  2001/05/11 13:27:37  tng
    * Copyright update.
    *
  @@ -85,6 +88,7 @@
   #include <internal/XMLReader.hpp>
   #include <internal/XMLScanner.hpp>
   #include <validators/datatype/InvalidDatatypeValueException.hpp>
  +#include <validators/datatype/InvalidDatatypeFacetException.hpp>
   #include <validators/schema/SchemaSymbols.hpp>
   #include <validators/schema/SchemaValidator.hpp>
   #include <validators/schema/SubstitutionGroupComparator.hpp>
  @@ -96,10 +100,11 @@
   
       XMLValidator(errReporter)
       , fGrammarResolver(0)
  +    , fSchemaGrammar(0)
       , fTrailing(false)
  -    , fBufferDatatype(0)
       , fXsiType(0)
  -    , fNil(0)
  +    , fXsiTypeValidator(0)
  +    , fNil(false)
   {
   }
   
  @@ -144,19 +149,27 @@
       else if ((modelType == SchemaElementDecl::Mixed)
            ||  (modelType == SchemaElementDecl::Children))
       {
  -        // Get the element's content model or fault it in
  -        XMLContentModel* elemCM = elemDecl->getContentModel();
  +        // if nillable, it's an error to have value
  +        if (fNil) {
  +            if (childCount > 0 || XMLString::compareString(fDatatypeBuffer.getRawBuffer(), XMLUni::fgZeroLenString))
  +                emitError(XMLValid::NilAttrNotEmpty, elemDecl->getFullName());
  +
  +        }
  +        else {
  +            // Get the element's content model or fault it in
  +            XMLContentModel* elemCM = elemDecl->getContentModel();
   
  -        // Ask it to validate and return its return
  -        int result = elemCM->validateContent(children, childCount, getScanner()->getEmptyNamespaceId());
  -        if (result != -1) {
  -            result = elemCM->validateContentSpecial(children
  -                                                  , childCount
  -                                                  , getScanner()->getEmptyNamespaceId()
  -                                                  , fGrammarResolver
  -                                                  , getScanner()->getURIStringPool());
  +            // Ask it to validate and return its return
  +            int result = elemCM->validateContent(children, childCount, getScanner()->getEmptyNamespaceId());
  +            if (result != -1) {
  +                result = elemCM->validateContentSpecial(children
  +                                                      , childCount
  +                                                      , getScanner()->getEmptyNamespaceId()
  +                                                      , fGrammarResolver
  +                                                      , getScanner()->getURIStringPool());
  +            }
  +            return result;
           }
  -        return result;
       }
       else if (modelType == SchemaElementDecl::Simple)
       {
  @@ -166,7 +179,7 @@
               try {
                   DatatypeValidator* fCurrentDV = ((SchemaElementDecl*)elemDecl)->getDatatypeValidator();
                   // If there is xsi:type validator, substitute it.
  -                if (!fXsiTypeValidator) {
  +                if (fXsiTypeValidator) {
                       fCurrentDV = fXsiTypeValidator;
                       fXsiTypeValidator = 0;
                   }
  @@ -211,12 +224,12 @@
               } catch (InvalidDatatypeValueException idve) {
                   emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
               }
  +            catch (InvalidDatatypeFacetException idve) {
  +                emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
  +            }
               catch (...) {
                   emitError(XMLValid::GenericError);
               }
  -            fNil = false;
  -            fBufferDatatype=false;
  -            fDatatypeBuffer.reset();
           }
       }
        else
  @@ -224,6 +237,8 @@
           ThrowXML(RuntimeException, XMLExcepts::CM_UnknownCMType);
       }
   
  +    fDatatypeBuffer.reset();
  +    fNil = false;
       fTrailing=false;
   
       // Went ok, so return success
  @@ -309,6 +324,9 @@
               } catch (InvalidDatatypeValueException idve) {
                   emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
               }
  +            catch (InvalidDatatypeFacetException idve) {
  +                emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
  +            }
               catch (...) {
                   emitError(XMLValid::GenericError);
               }
  @@ -365,6 +383,9 @@
                                       } catch (InvalidDatatypeValueException idve) {
                                           emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
                                       }
  +                                    catch (InvalidDatatypeFacetException idve) {
  +                                        emitError (XMLValid::DatatypeError, idve.getType(), idve.getMessage());
  +                                    }
                                       catch (...) {
                                           emitError(XMLValid::GenericError);
                                       }
  @@ -600,10 +621,7 @@
           emitError(XMLValid::NillNotAllowed, elemDef->getFullName());
       }
   
  -    if (((SchemaElementDecl*) elemDef)->getModelType() == SchemaElementDecl::Simple) {
  -        fBufferDatatype = true;
  -        fDatatypeBuffer.reset();
  -    }
  +    fDatatypeBuffer.reset();
   }
   
   void SchemaValidator::preContentValidation(bool reuseGrammar)
  @@ -840,9 +858,8 @@
           // Add this char to the target buffer
           toFill.append(nextCh);
   
  -        // stored the content if we are in simple type element string content
  -        if (fBufferDatatype)
  -            fDatatypeBuffer.append(nextCh);
  +        // stored the content for validation later
  +        fDatatypeBuffer.append(nextCh);
   
           // And move up to the next character in the source
           srcPtr++;
  
  
  
  1.6       +3 -5      xml-xerces/c/src/validators/schema/SchemaValidator.hpp
  
  Index: SchemaValidator.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/validators/schema/SchemaValidator.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SchemaValidator.hpp	2001/05/11 13:27:37	1.5
  +++ SchemaValidator.hpp	2001/05/11 15:17:48	1.6
  @@ -56,6 +56,9 @@
   
   /*
    * $Log: SchemaValidator.hpp,v $
  + * Revision 1.6  2001/05/11 15:17:48  tng
  + * Schema: Nillable fixes.
  + *
    * Revision 1.5  2001/05/11 13:27:37  tng
    * Copyright update.
    *
  @@ -196,10 +199,6 @@
       //  fDatatypeBuffer
       //      Buffer for simple type element string content
       //
  -    //  fBufferDatatype
  -    //      Indicate a simple type element is being scanned, and its
  -    //      string content should be stored in fDatatypeBuffer
  -    //
       //  fTrailing
       //      Previous chunk had a trailing space
       // -----------------------------------------------------------------------
  @@ -210,7 +209,6 @@
   
       DatatypeValidator* fXsiTypeValidator;
   
  -    bool fBufferDatatype;
       XMLBuffer fDatatypeBuffer;
       bool fTrailing;
   };
  
  
  

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