From 858e15ede2eaceda5eee190ed8cb41f56de0555c Mon Sep 17 00:00:00 2001
From: Neil Graham <neilg@apache.org>
Date: Fri, 19 Dec 2003 07:20:03 +0000
Subject: [PATCH] when validating a skipped element or attribute, we should not
 look for a declaration.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175604 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/IGXMLScanner.cpp  |  5 -----
 src/xercesc/internal/IGXMLScanner2.cpp | 24 +++++++++++++-----------
 src/xercesc/internal/SGXMLScanner.cpp  | 26 ++++++++++++--------------
 3 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp
index 05f382c47..04e1e57e3 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -2786,11 +2786,6 @@ bool IGXMLScanner::scanStartTagNS(bool& gotData)
             if(fGrammarType == Grammar::SchemaGrammarType)
             {
                 ((SchemaElementDecl *)(elemDecl))->setValidity(PSVIDefs::INVALID);
-                if (getPSVIHandler())
-                {
-                    // REVISIT:                
-                    // PSVIElement->setValidity(PSVIItem::VALIDITY_INVALID);
-                }
             }
         }
     }
diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index 1169bfa9c..1bc6846e8 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -124,7 +124,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
     // know what's best.  REVISIT:  don't modify grammar at all; eliminate
     // this step...
     ComplexTypeInfo *currType = 0;
-    if(fGrammar->getGrammarType() == Grammar::SchemaGrammarType)
+    if(fGrammar->getGrammarType() == Grammar::SchemaGrammarType && fValidate)
         currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
     const bool hasDefs = (currType && fValidate)
             ? currType->resetDefs()
@@ -245,11 +245,14 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                         //if schema, see if we should lax or skip the validation of this attribute
                         if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
 
-                            SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
-                            if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
-                                RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
-                                if (attRegistry) {
-                                    attDefForWildCard = attRegistry->get(suffPtr);
+                            if(!skipThisOne)
+                            {
+                                SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
+                                if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
+                                    RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
+                                    if (attRegistry) {
+                                        attDefForWildCard = attRegistry->get(suffPtr);
+                                    }
                                 }
                             }
                         }
@@ -307,10 +310,9 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
             //  Find this attribute within the parent element. We pass both
             //  the uriID/name and the raw QName buffer, since we don't know
             //  how the derived validator and its elements store attributes.
-            if (!attDef) {
-                if(fGrammarType == Grammar::SchemaGrammarType) 
-                    attDef = ((SchemaElementDecl *)elemDecl)->getAttDef( suffPtr , uriId);
-                else 
+            else
+            {
+                if(fGrammarType == Grammar::DTDGrammarType) 
                     attDef = ((DTDElementDecl *)elemDecl)->getAttDef ( namePtr);
             } 
 
@@ -484,7 +486,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     }
                 }
 
-                if (fValidate && !skipThisOne) {
+                if (fValidate ) {
                     fValidator->validateAttrValue
                     (
                         attDefForWildCard
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index dea53b163..b4380c44d 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -2272,7 +2272,9 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
     //  Ask the element to clear the 'provided' flag on all of the att defs
     //  that it owns, and to return us a boolean indicating whether it has
     //  any defs.
-    ComplexTypeInfo *currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
+    ComplexTypeInfo *currType = (fValidate)
+                ?((SchemaValidator*)fValidator)->getCurrentTypeInfo()
+                :0;
     const bool hasDefs = (currType && fValidate) 
             ? currType->resetDefs()
             : elemDecl->resetDefs();
@@ -2391,11 +2393,14 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                         //if schema, see if we should lax or skip the validation of this attribute
                         if (anyAttributeValidation(attWildCard, uriId, skipThisOne, laxThisOne)) {
 
-                            SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
-                            if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
-                                RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
-                                if (attRegistry) {
-                                    attDefForWildCard = attRegistry->get(suffPtr);
+                            if(!skipThisOne)
+                            {
+                                SchemaGrammar* sGrammar = (SchemaGrammar*) fGrammarResolver->getGrammar(getURIText(uriId));
+                                if (sGrammar && sGrammar->getGrammarType() == Grammar::SchemaGrammarType) {
+                                    RefHashTableOf<XMLAttDef>* attRegistry = sGrammar->getAttributeDeclRegistry();
+                                    if (attRegistry) {
+                                        attDefForWildCard = attRegistry->get(suffPtr);
+                                    }
                                 }
                             }
                         }
@@ -2444,13 +2449,6 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                 }
             }
 
-            //  Find this attribute within the parent element. We pass both
-            //  the uriID/name and the raw QName buffer, since we don't know
-            //  how the derived validator and its elements store attributes.
-            if (!attDef) {
-                attDef = ((SchemaElementDecl *)elemDecl)->getAttDef(suffPtr, uriId);
-            }
-
             // now need to prepare for duplicate detection
             if(attDef)
             {
@@ -2595,7 +2593,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     }
                 }
 
-                if (fValidate && !skipThisOne) {
+                if (fValidate ) {
                     fValidator->validateAttrValue
                     (
                         attDefForWildCard
-- 
GitLab