knoaman     2003/12/11 11:26:28

  Modified:    c/src/xercesc/validators/schema TraverseSchema.hpp
                        TraverseSchema.cpp SchemaInfo.hpp SchemaInfo.cpp
                        GeneralAttributeCheck.hpp GeneralAttributeCheck.cpp
  Log:
  Store non schema attributes from parent in XSAnnotation
  
  Revision  Changes    Path
  1.31      +5 -1      xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp
  
  Index: TraverseSchema.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.hpp,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- TraverseSchema.hpp        23 Nov 2003 16:32:21 -0000      1.30
  +++ TraverseSchema.hpp        11 Dec 2003 19:26:27 -0000      1.31
  @@ -172,6 +172,7 @@
                                            const XMLCh* const schemaURL);
       void                traverseSchemaHeader(const DOMElement* const schemaRoot);
       XSAnnotation*       traverseAnnotationDecl(const DOMElement* const childElem,
  +                                               ValueVectorOf<DOMNode*>* const 
nonXSAttList,
                                                  const bool topLevel = false);
       void                traverseInclude(const DOMElement* const childElem);
       void                traverseImport(const DOMElement* const childElem);
  @@ -726,6 +727,8 @@
       void processKeyRefFor(SchemaInfo* const aSchemaInfo,
                             ValueVectorOf<SchemaInfo*>* const infoList);
   
  +    void processAttValue(const XMLCh* const attVal, XMLBuffer& aBuf);
  +
       // Spaces are not allowed in URI, so %20 is used instead.
       // Convert %20 to spaces before resolving the URI
       void normalizeURI(const XMLCh* const systemURI, XMLBuffer& normalizedURI);
  @@ -792,6 +795,7 @@
       ValueVectorOf<SchemaElementDecl*>*             fIC_Elements;
       ValueVectorOf<const DOMElement*>*              fDeclStack;
       ValueVectorOf<unsigned int>**                  fGlobalDeclarations;
  +    ValueVectorOf<DOMNode*>*                       fNonXSAttList;
       RefHashTableOf<ValueVectorOf<DOMElement*> >*   fIC_NodeListNS;
       RefHashTableOf<ValueVectorOf<unsigned int> >*  fIC_NamespaceDepthNS;
       RefHash2KeysTableOf<XMLCh>*                    fNotationRegistry;
  
  
  
  1.99      +219 -75   xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp
  
  Index: TraverseSchema.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/TraverseSchema.cpp,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- TraverseSchema.cpp        23 Nov 2003 16:32:21 -0000      1.98
  +++ TraverseSchema.cpp        11 Dec 2003 19:26:27 -0000      1.99
  @@ -236,6 +236,7 @@
       , fIC_Elements(0)
       , fDeclStack(0)
       , fGlobalDeclarations(0)
  +    , fNonXSAttList(0)
       , fNotationRegistry(0)
       , fRedefineComponents(0)
       , fIdentityConstraintNames(0)
  @@ -429,7 +430,10 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(schemaRoot, GeneralAttributeCheck::E_Schema, 
this, true);
  +    fAttributeCheck.checkAttributes(
  +        schemaRoot, GeneralAttributeCheck::E_Schema, this
  +        , true, fSchemaInfo->getNonXSAttList()
  +    );
   
       retrieveNamespaceMapping(schemaRoot);
       unsigned short elemAttrDefaultQualified = 0;
  @@ -450,13 +454,17 @@
   }
   
   
  -XSAnnotation* TraverseSchema::traverseAnnotationDecl(const DOMElement* const 
annotationElem,
  -                                                     const bool topLevel) {
  +XSAnnotation*
  +TraverseSchema::traverseAnnotationDecl(const DOMElement* const annotationElem,
  +                                       ValueVectorOf<DOMNode*>* const nonXSAttList,
  +                                       const bool topLevel) {
   
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(annotationElem, 
GeneralAttributeCheck::E_Annotation, this, topLevel);
  +    fAttributeCheck.checkAttributes(
  +        annotationElem, GeneralAttributeCheck::E_Annotation, this, topLevel
  +    );
   
       const XMLCh* contents = 0;
       for (DOMElement* child = XUtil::getFirstChildElement(annotationElem);
  @@ -487,7 +495,51 @@
       }
   
       if (contents)
  -        return new (fGrammarPoolMemoryManager) XSAnnotation(contents, 
fGrammarPoolMemoryManager);
  +    {
  +        unsigned int nonXSAttSize = nonXSAttList->size();
  +
  +        if (nonXSAttSize)
  +        {
  +            int annotTokenStart = XMLString::patternMatch(
  +                contents, SchemaSymbols::fgELT_ANNOTATION);
  +
  +            if (annotTokenStart == -1) // somthing is wrong
  +                return 0;
  +
  +            // set annotation element
  +            fBuffer.set(contents, annotTokenStart + 10);
  +
  +            for (unsigned int i=0; i<nonXSAttSize; i++)
  +            {
  +                DOMNode* attNode = nonXSAttList->elementAt(i);
  +
  +                if (!XMLString::equals(
  +                        annotationElem->getAttributeNS(
  +                           attNode->getNamespaceURI(), attNode->getLocalName())
  +                        , XMLUni::fgZeroLenString)
  +                   )
  +                {
  +                    continue;
  +                }
  +
  +                fBuffer.append(chSpace);
  +                fBuffer.append(attNode->getNodeName());
  +                fBuffer.append(chEqual);
  +                fBuffer.append(chDoubleQuote);
  +                processAttValue(attNode->getNodeValue(), fBuffer);
  +                fBuffer.append(chDoubleQuote);
  +            }
  +
  +            // add remaining annotation content
  +            fBuffer.append(contents + annotTokenStart + 10);
  +
  +            return new (fGrammarPoolMemoryManager) 
XSAnnotation(fBuffer.getRawBuffer(), fGrammarPoolMemoryManager);
  +        }
  +        else
  +        {
  +            return new (fGrammarPoolMemoryManager) XSAnnotation(contents, 
fGrammarPoolMemoryManager);
  +        }
  +    }
   
       return 0;
   }
  @@ -505,23 +557,24 @@
     */
   void TraverseSchema::preprocessInclude(const DOMElement* const elem) {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Include, this, 
true);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Include, this, true);
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // First, handle any ANNOTATION declaration
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0)
           reportSchemaError(elem, XMLUni::fgXMLErrDomain, 
XMLErrs::OnlyAnnotationExpected);
   
       if (fAnnotation)
  -        fSchemaGrammar->addAnnotation(fAnnotation);
  +        delete fAnnotation;//fSchemaGrammar->addAnnotation(fAnnotation);
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Get 'schemaLocation' attribute
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       const XMLCh* schemaLocation = getElementAttValue(elem, 
SchemaSymbols::fgATT_SCHEMALOCATION);
   
       if (!schemaLocation || !*schemaLocation) {
  @@ -652,23 +705,24 @@
     */
   void TraverseSchema::preprocessImport(const DOMElement* const elem) {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Import, this, 
true);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Import, this, true);
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // First, handle any ANNOTATION declaration
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       if (checkContent(elem, XUtil::getFirstChildElement(elem), true) != 0)
           reportSchemaError(elem, XMLUni::fgXMLErrDomain, 
XMLErrs::OnlyAnnotationExpected);
   
       if (fAnnotation)
  -        fSchemaGrammar->addAnnotation(fAnnotation);
  +        delete fAnnotation;//fSchemaGrammar->addAnnotation(fAnnotation);
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Handle 'namespace' attribute
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       const XMLCh* nameSpace = getElementAttValue(elem, 
SchemaSymbols::fgATT_NAMESPACE);
   
       if (XMLString::equals(nameSpace, fTargetNSURIString)) {
  @@ -842,10 +896,12 @@
     */
   void TraverseSchema::preprocessRedefine(const DOMElement* const redefineElem) {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(redefineElem, 
GeneralAttributeCheck::E_Redefine, this, true);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        redefineElem, GeneralAttributeCheck::E_Redefine, this, true
  +    );
   
       // First, we look through the children of redefineElem. Each one will
       // correspond to an element of the redefined schema that we need to
  @@ -915,14 +971,16 @@
                                          const int modelGroupType)
   {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Sequence, this);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Sequence, this, false, fNonXSAttList
  +    );
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Process contents
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
       Janitor<XSAnnotation> janAnnot(fAnnotation);
       ContentSpecNode* left = 0;
  @@ -1087,16 +1145,18 @@
   
       if (!dv) {
   
  -        // ------------------------------------------------------------------
  +        // -------------------------------------------------------------------
           // Check attributes
  -        // ------------------------------------------------------------------
  +        // -------------------------------------------------------------------
           unsigned short scope = (topLevel) ? 
GeneralAttributeCheck::E_SimpleTypeGlobal
                                             : 
GeneralAttributeCheck::E_SimpleTypeLocal;
   
  -        fAttributeCheck.checkAttributes(childElem, scope, this, topLevel);
  +        fAttributeCheck.checkAttributes(
  +            childElem, scope, this, topLevel, fNonXSAttList
  +        );
   
           // Circular constraint checking
  -        if (fCurrentTypeNameStack->containsElement(fullTypeNameId)){
  +        if (fCurrentTypeNameStack->containsElement(fullTypeNameId)) {
   
               reportSchemaError(childElem, XMLUni::fgXMLErrDomain, 
XMLErrs::NoCircularDefinition, name);
               return 0;
  @@ -1228,7 +1288,7 @@
       // -----------------------------------------------------------------------
       unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_ComplexTypeGlobal
                                         : GeneralAttributeCheck::E_ComplexTypeLocal;
  -    fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
  +    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
   
       // -----------------------------------------------------------------------
       // Create a new instance
  @@ -1410,7 +1470,7 @@
       // ------------------------------------------------------------------
       unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_GroupGlobal
                                         : GeneralAttributeCheck::E_GroupRef;
  -    fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
  +    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
   
       // ------------------------------------------------------------------
       // Handle "ref="
  @@ -1581,7 +1641,7 @@
       // ------------------------------------------------------------------
       unsigned short scope = (topLevel) ? 
GeneralAttributeCheck::E_AttributeGroupGlobal
                                         : GeneralAttributeCheck::E_AttributeGroupRef;
  -    fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
  +    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
   
       // ------------------------------------------------------------------
       // Handle "ref="
  @@ -1733,7 +1793,9 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Any, this);
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Any, this, false, fNonXSAttList
  +    );
   
       // ------------------------------------------------------------------
       // First, handle any ANNOTATION declaration
  @@ -1900,14 +1962,16 @@
   ContentSpecNode*
   TraverseSchema::traverseAll(const DOMElement* const elem) {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_All, this);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_All, this, false, fNonXSAttList
  +    );
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Process contents
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       DOMElement* child = checkContent(elem, XUtil::getFirstChildElement(elem), true);
       Janitor<XSAnnotation> janAnnot(fAnnotation);
   
  @@ -2029,10 +2093,12 @@
       // ------------------------------------------------------------------
       // Check attributes
       // ------------------------------------------------------------------
  -    unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_AttributeGlobal
  -                                      : (refEmpty) ? 
GeneralAttributeCheck::E_AttributeLocal
  -                                                   : 
GeneralAttributeCheck::E_AttributeRef;
  -    fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
  +    unsigned short scope = (topLevel)
  +        ? GeneralAttributeCheck::E_AttributeGlobal
  +        : (refEmpty) ? GeneralAttributeCheck::E_AttributeLocal
  +                     : GeneralAttributeCheck::E_AttributeRef;
  +
  +    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
   
       const XMLCh* defaultVal = getElementAttValue(elem, 
SchemaSymbols::fgATT_DEFAULT);
       const XMLCh* fixedVal = getElementAttValue(elem, SchemaSymbols::fgATT_FIXED);
  @@ -2200,7 +2266,7 @@
                   attType = XMLAttDef::Simple;
               }
           }
  -        else 
  +        else
               attType = XMLAttDef::Simple;
   
           dv = dvBack;
  @@ -2415,7 +2481,7 @@
       unsigned short scope = (topLevel) ? GeneralAttributeCheck::E_ElementGlobal
                                         : GeneralAttributeCheck::E_ElementLocal;
   
  -    fAttributeCheck.checkAttributes(elem, scope, this, topLevel);
  +    fAttributeCheck.checkAttributes(elem, scope, this, topLevel, fNonXSAttList);
   
       // check annotation
       const DOMElement* content = checkContent(elem, 
XUtil::getFirstChildElement(elem), true);
  @@ -2613,14 +2679,16 @@
   
   const XMLCh* TraverseSchema::traverseNotationDecl(const DOMElement* const elem) {
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Notation, this, 
true);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Notation, this, true, fNonXSAttList
  +    );
   
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Process notation attributes/elements
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       const XMLCh* name = getElementAttValue(elem, SchemaSymbols::fgATT_NAME);
       bool         nameEmpty = (!name || !*name) ? true : false;
   
  @@ -2728,7 +2796,9 @@
       DatatypeValidator* baseValidator = 0;
       const XMLCh*       baseTypeName = getElementAttValue(contentElem, 
SchemaSymbols::fgATT_ITEMTYPE);
   
  -    fAttributeCheck.checkAttributes(contentElem, GeneralAttributeCheck::E_List, 
this);
  +    fAttributeCheck.checkAttributes(
  +        contentElem, GeneralAttributeCheck::E_List, this, false, fNonXSAttList
  +    );
   
       if (XUtil::getNextSiblingElement(contentElem) != 0) {
           reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, 
XMLErrs::SimpleTypeContentError);
  @@ -2833,7 +2903,9 @@
       DatatypeValidator* newDV = 0;
       const XMLCh*       baseTypeName = getElementAttValue(contentElem, 
SchemaSymbols::fgATT_BASE);
   
  -    fAttributeCheck.checkAttributes(contentElem, 
GeneralAttributeCheck::E_Restriction, this);
  +    fAttributeCheck.checkAttributes(
  +        contentElem, GeneralAttributeCheck::E_Restriction, this, false, 
fNonXSAttList
  +    );
   
       if (XUtil::getNextSiblingElement(contentElem) != 0) {
           reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, 
XMLErrs::SimpleTypeContentError);
  @@ -2922,11 +2994,12 @@
                   // REVISIT
                   // check for annotation content - we are not checking whether the
                   // return is empty or not. If not empty we should report an error
  +                fAttributeCheck.checkAttributes(
  +                    content, scope, this, false, fNonXSAttList
  +                );
                   checkContent(rootElem, XUtil::getFirstChildElement(content), true);
   
                   const XMLCh* attValue = 
content->getAttribute(SchemaSymbols::fgATT_VALUE);
  -                fAttributeCheck.checkAttributes(content, scope, this);
  -
                   if (facets == 0) {
                       facets = new (fGrammarPoolMemoryManager) 
RefHashTableOf<KVStringPair>(29, true, fGrammarPoolMemoryManager);
                   }
  @@ -3072,7 +3145,9 @@
                                   int baseRefContext,
                                   Janitor<XSAnnotation>* const janAnnot) {
   
  -    fAttributeCheck.checkAttributes(contentElem, GeneralAttributeCheck::E_Union, 
this);
  +    fAttributeCheck.checkAttributes(
  +        contentElem, GeneralAttributeCheck::E_Union, this, false, fNonXSAttList
  +    );
   
       if (XUtil::getNextSiblingElement(contentElem) != 0) {
           reportSchemaError(contentElem, XMLUni::fgXMLErrDomain, 
XMLErrs::SimpleTypeContentError);
  @@ -3225,7 +3300,10 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(contentDecl, 
GeneralAttributeCheck::E_SimpleContent, this);
  +    fAttributeCheck.checkAttributes(
  +        contentDecl, GeneralAttributeCheck::E_SimpleContent
  +        , this, false, fNonXSAttList
  +    );
   
       // -----------------------------------------------------------------------
       // Set the content type to be simple, and initialize content spec handle
  @@ -3258,12 +3336,18 @@
   
       if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_RESTRICTION)) {
   
  -        fAttributeCheck.checkAttributes(simpleContent, 
GeneralAttributeCheck::E_Restriction, this);
  +        fAttributeCheck.checkAttributes(
  +            simpleContent, GeneralAttributeCheck::E_Restriction
  +            , this, false, fNonXSAttList
  +        );
           typeInfo->setDerivedBy(SchemaSymbols::XSD_RESTRICTION);
       }
       else if (XMLString::equals(contentName, SchemaSymbols::fgATTVAL_EXTENSION)) {
   
  -        fAttributeCheck.checkAttributes(simpleContent, 
GeneralAttributeCheck::E_Extension, this);
  +        fAttributeCheck.checkAttributes(
  +            simpleContent, GeneralAttributeCheck::E_Extension
  +            , this, false, fNonXSAttList
  +        );
           typeInfo->setDerivedBy(SchemaSymbols::XSD_EXTENSION);
       }
       else {
  @@ -3599,10 +3683,13 @@
                                                   const bool isMixed,
                                                   Janitor<XSAnnotation>* const 
janAnnot)
   {
  -    // ------------------------------------------------------------------
  +    // -----------------------------------------------------------------------
       // Check attributes
  -    // ------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(contentDecl, 
GeneralAttributeCheck::E_ComplexContent, this);
  +    // -----------------------------------------------------------------------
  +    fAttributeCheck.checkAttributes(
  +        contentDecl, GeneralAttributeCheck::E_ComplexContent
  +        , this, false, fNonXSAttList
  +    );
   
       // -----------------------------------------------------------------------
       // Determine whether the content is mixed, or element-only
  @@ -3733,7 +3820,9 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_AnyAttribute, 
this);
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_AnyAttribute, this, false, fNonXSAttList
  +    );
   
       // ------------------------------------------------------------------
       // First, handle any ANNOTATION declaration
  @@ -3851,7 +3940,9 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_Key, this);
  +    fAttributeCheck.checkAttributes(
  +        icElem, GeneralAttributeCheck::E_Key, this, false, fNonXSAttList
  +    );
   
       // -----------------------------------------------------------------------
       // Create identity constraint
  @@ -3912,7 +4003,9 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_Unique, this);
  +    fAttributeCheck.checkAttributes(
  +        icElem, GeneralAttributeCheck::E_Unique, this, false, fNonXSAttList
  +    );
   
       // -----------------------------------------------------------------------
       // Create identity constraint
  @@ -3975,7 +4068,9 @@
       // -----------------------------------------------------------------------
       // Check Attributes
       // -----------------------------------------------------------------------
  -    fAttributeCheck.checkAttributes(icElem, GeneralAttributeCheck::E_KeyRef, this);
  +    fAttributeCheck.checkAttributes(
  +        icElem, GeneralAttributeCheck::E_KeyRef, this, false, fNonXSAttList
  +    );
   
       // -----------------------------------------------------------------------
       // Verify that key reference "refer" attribute is valid
  @@ -4069,7 +4164,9 @@
           return false;
       }
   
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Selector, this);
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_Selector, this, false, fNonXSAttList
  +    );
       checkContent(icElem, XUtil::getFirstChildElement(elem), true);
       if (fAnnotation)
       {
  @@ -4147,7 +4244,9 @@
           }
           else {
               // General Attribute Checking
  -            fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_Field, 
this);
  +            fAttributeCheck.checkAttributes(
  +                elem, GeneralAttributeCheck::E_Field, this, false, fNonXSAttList
  +            );
               checkContent(icElem, XUtil::getFirstChildElement(elem), true);
               if (fAnnotation)
                        {
  @@ -4263,7 +4362,10 @@
           const XMLCh* name = child->getLocalName();
   
           if (XMLString::equals(name, SchemaSymbols::fgELT_ANNOTATION)) {
  -            fSchemaGrammar->addAnnotation(traverseAnnotationDecl(child, true));
  +            fSchemaGrammar->addAnnotation(
  +                traverseAnnotationDecl(
  +                    child, fSchemaInfo->getNonXSAttList(), true)
  +            );
           }
           else if (XMLString::equals(name, SchemaSymbols::fgELT_INCLUDE)) {
               traverseInclude(child);
  @@ -4295,7 +4397,10 @@
           }
   
           if (XMLString::equals(name, SchemaSymbols::fgELT_ANNOTATION)) {
  -            fSchemaGrammar->addAnnotation(traverseAnnotationDecl(child, true));
  +            fSchemaGrammar->addAnnotation(
  +                traverseAnnotationDecl(
  +                    child, fSchemaInfo->getNonXSAttList(), true)
  +            );
           }
           else if (XMLString::equals(name, SchemaSymbols::fgELT_SIMPLETYPE)) {
   
  @@ -4472,7 +4577,7 @@
   
       if (XMLString::equals(content->getLocalName(), 
SchemaSymbols::fgELT_ANNOTATION)) {
   
  -        fAnnotation = traverseAnnotationDecl(content);
  +        fAnnotation = traverseAnnotationDecl(content, fNonXSAttList);
           content = XUtil::getNextSiblingElement(content);
   
           if (!content) { // must be followed by content
  @@ -4635,7 +4740,9 @@
                                         const XMLCh* const refName)
   {
       // check attributes
  -    fAttributeCheck.checkAttributes(elem, GeneralAttributeCheck::E_ElementRef, 
this);
  +    fAttributeCheck.checkAttributes(
  +        elem, GeneralAttributeCheck::E_ElementRef, this, false, fNonXSAttList
  +    );
   
       // handle annotation
       DOMElement* content = checkContent(elem, XUtil::getFirstChildElement(elem), 
true);
  @@ -8110,6 +8217,7 @@
       for(unsigned int i=0; i < ENUM_ELT_SIZE; i++)
           fGlobalDeclarations[i] = new (fMemoryManager) ValueVectorOf<unsigned 
int>(8, fMemoryManager);
   
  +    fNonXSAttList = new (fMemoryManager) ValueVectorOf<DOMNode*>(4, fMemoryManager);
       fNotationRegistry = new (fMemoryManager) RefHash2KeysTableOf<XMLCh>(13, (bool) 
false, fMemoryManager);
       fSchemaInfoList = new (fMemoryManager) RefHash2KeysTableOf<SchemaInfo>(29, 
fMemoryManager);
       fPreprocessedNodes = new (fMemoryManager) RefHashTableOf<SchemaInfo>
  @@ -8134,6 +8242,7 @@
   
       fMemoryManager->deallocate(fGlobalDeclarations);//delete [] fGlobalDeclarations;
   
  +    delete fNonXSAttList;
       delete fNotationRegistry;
       delete fRedefineComponents;
       delete fIdentityConstraintNames;
  @@ -8398,6 +8507,41 @@
                   buildValidSubstitutionListF(elem, elemDecl, subsElemDecl);
               }
           }
  +    }
  +}
  +
  +void TraverseSchema::processAttValue(const XMLCh* const attVal,
  +                                     XMLBuffer& aBuf)
  +{
  +    // REVISIT-KN: assuming that attVal is not NULL
  +    //
  +    // normally, nothing will happen
  +    const XMLCh* srcVal = attVal;
  +    XMLCh nextCh = *srcVal;
  +    while (nextCh)
  +    {
  +        if (nextCh == chDoubleQuote)
  +        {
  +            aBuf.append(chAmpersand);
  +            aBuf.append(XMLUni::fgQuot);
  +            aBuf.append(chSemiColon);
  +        }
  +        else if (nextCh == chCloseAngle)
  +        {
  +            aBuf.append(chAmpersand);
  +            aBuf.append(XMLUni::fgGT);
  +            aBuf.append(chSemiColon);
  +        }
  +        else if (nextCh == chAmpersand)
  +        {
  +            aBuf.append(chAmpersand);
  +            aBuf.append(XMLUni::fgAmp);
  +            aBuf.append(chSemiColon);
  +        }
  +        else
  +            aBuf.append(nextCh);
  +
  +        nextCh = *++srcVal;
       }
   }
   
  
  
  
  1.15      +8 -1      xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.hpp
  
  Index: SchemaInfo.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.hpp,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SchemaInfo.hpp    16 May 2003 21:43:21 -0000      1.14
  +++ SchemaInfo.hpp    11 Dec 2003 19:26:27 -0000      1.15
  @@ -137,6 +137,7 @@
       BaseRefVectorEnumerator<SchemaInfo>   getImportingListEnumerator() const;
       ValueVectorOf<const DOMElement*>* getRecursingAnonTypes() const;
       ValueVectorOf<const XMLCh*>*      getRecursingTypeNames() const;
  +    ValueVectorOf<DOMNode*>* getNonXSAttList() const;
   
       // -----------------------------------------------------------------------
       //  Setter methods
  @@ -196,6 +197,7 @@
       ValueVectorOf<const DOMElement*>* fRecursingAnonTypes;
       ValueVectorOf<const XMLCh*>*      fRecursingTypeNames;
       ValueVectorOf<DOMElement*>*       fTopLevelComponents[C_Count];
  +    ValueVectorOf<DOMNode*>*          fNonXSAttList;
       MemoryManager*                    fMemoryManager;
   };
   
  @@ -268,6 +270,11 @@
   SchemaInfo::getRecursingTypeNames() const {
   
       return fRecursingTypeNames;
  +}
  +
  +inline ValueVectorOf<DOMNode*>* SchemaInfo::getNonXSAttList() const
  +{
  +    return fNonXSAttList;
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.11      +8 -0      xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.cpp
  
  Index: SchemaInfo.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaInfo.cpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SchemaInfo.cpp    16 May 2003 21:43:21 -0000      1.10
  +++ SchemaInfo.cpp    11 Dec 2003 19:26:27 -0000      1.11
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.11  2003/12/11 19:26:27  knoaman
  + * Store non schema attributes from parent in XSAnnotation
  + *
    * Revision 1.10  2003/05/16 21:43:21  knoaman
    * Memory manager implementation: Modify constructors to pass in the memory manager.
    *
  @@ -148,11 +151,13 @@
       , fImportedNSList(0)
       , fRecursingAnonTypes(0)
       , fRecursingTypeNames(0)
  +    , fNonXSAttList(0)
       , fMemoryManager(manager)
   {
       fImportingInfoList = new (fMemoryManager) RefVectorOf<SchemaInfo>(4, false, 
fMemoryManager);
       for (unsigned int i = 0; i < C_Count; i++)
           fTopLevelComponents[i] = 0;
  +    fNonXSAttList = new (fMemoryManager) ValueVectorOf<DOMNode*>(2, fMemoryManager);
   }
   
   
  @@ -185,6 +190,9 @@
           delete fTopLevelComponents[i];
           fTopLevelComponents[i] = 0;
       }
  +
  +    delete fNonXSAttList;
  +    fNonXSAttList = 0;
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.11      +4 -3      
xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.hpp
  
  Index: GeneralAttributeCheck.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.hpp,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- GeneralAttributeCheck.hpp 12 Nov 2003 20:35:31 -0000      1.10
  +++ GeneralAttributeCheck.hpp 11 Dec 2003 19:26:27 -0000      1.11
  @@ -81,7 +81,7 @@
   // ---------------------------------------------------------------------------
   class TraverseSchema;
   class DOMElement;
  -
  +class DOMNode;
   
   class VALIDATORS_EXPORT GeneralAttributeCheck : public XMemory
   {
  @@ -241,7 +241,8 @@
       void checkAttributes(const DOMElement* const elem,
                            const unsigned short elemContext,
                            TraverseSchema* const schema,
  -                         const bool isTopLevel = false);
  +                         const bool isTopLevel = false,
  +                         ValueVectorOf<DOMNode*>* const nonXSAttList = 0);
   
       // -----------------------------------------------------------------------
       //  Notification that lazy data has been deleted
  
  
  
  1.17      +23 -29    
xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.cpp
  
  Index: GeneralAttributeCheck.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/c/src/xercesc/validators/schema/GeneralAttributeCheck.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- GeneralAttributeCheck.cpp 12 Nov 2003 20:35:31 -0000      1.16
  +++ GeneralAttributeCheck.cpp 11 Dec 2003 19:26:27 -0000      1.17
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.17  2003/12/11 19:26:27  knoaman
  + * Store non schema attributes from parent in XSAnnotation
  + *
    * Revision 1.16  2003/11/12 20:35:31  peiyongz
    * Stateless Grammar: ValidationContext
    *
  @@ -361,11 +364,14 @@
   GeneralAttributeCheck::checkAttributes(const DOMElement* const elem,
                                          const unsigned short elemContext,
                                          TraverseSchema* const schema,
  -                                       const bool isTopLevel) {
  +                                       const bool isTopLevel,
  +                                       ValueVectorOf<DOMNode*>* const nonXSAttList)
  +{
  +    if (nonXSAttList)
  +        nonXSAttList->removeAllElements();
   
  -    if (elem == 0 || !fAttMap || elemContext>=E_Count) {
  +    if (elem == 0 || !fAttMap || elemContext>=E_Count)
           return;
  -    }
   
       const XMLCh* elemName = elem->getLocalName();
       if (!XMLString::equals(SchemaSymbols::fgURI_SCHEMAFORSCHEMA, 
elem->getNamespaceURI())) {
  @@ -390,10 +396,20 @@
           DOMNode*     attribute = eltAttrs->item(i);
           const XMLCh* attName = attribute->getNodeName();
   
  +        // skip namespace declarations
  +        if (XMLString::equals(attName, XMLUni::fgXMLNSString)
  +            || XMLString::startsWith(attName, XMLUni::fgXMLNSColonString))
  +            continue;
  +
           // Bypass attributes that start with xml
  +        // add this to the list of "non-schema" attributes
           if ((*attName == chLatin_X || *attName == chLatin_x)
              && (*(attName+1) == chLatin_M || *(attName+1) == chLatin_m)
              && (*(attName+2) == chLatin_L || *(attName+2) == chLatin_l)) {
  +
  +           if (nonXSAttList)
  +                nonXSAttList->addElement(attribute);
  +
               continue;
           }
   
  @@ -410,32 +426,10 @@
   
                   schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain,
                       XMLErrs::AttributeDisallowed, attName, contextStr, elemName);
  -            } else {
  -
  -                // Try for a "lax" validation
  -                DatatypeValidator* dv = schema->getDatatypeValidator(attrURI, 
attribute->getLocalName());
  -
  -                if (dv) {
  -
  -                    const XMLCh* attrVal = attribute->getNodeValue();
  -
  -                    try {
  -                        dv->validate(attrVal, fValidationContext);
  -                    }
  -                    catch(const XMLException& excep) {
  -                        schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, 
XMLErrs::DisplayErrorMessage, excep.getMessage());
  -                    }
  -                    catch(const OutOfMemoryException&)
  -                    {
  -                        throw;
  -                    }
  -                    catch(...) {
  -                        schema->reportSchemaError(elem, XMLUni::fgXMLErrDomain, 
XMLErrs::InvalidAttValue, attrVal, attName);
  -                    }
  -                }
  -                // REVISIT:
  -                // If no dv found, store attribute info for a "lax" validation
  -                // after schema traversal ?? - KN
  +            }
  +            else if (nonXSAttList)
  +            {
  +                nonXSAttList->addElement(attribute);
               }
   
               continue;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to