From 62deeaeec5561acd775dc4823ac877c55f4e4269 Mon Sep 17 00:00:00 2001
From: Khaled Noaman <knoaman@apache.org>
Date: Wed, 29 Sep 2004 00:07:40 +0000
Subject: [PATCH] Fix for bug 1197. Disallow validating attributes when
 xsi:type is simple.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@176103 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/IGXMLScanner2.cpp |  9 ++++++++-
 src/xercesc/internal/SGXMLScanner.cpp  | 16 ++++++++++++----
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/xercesc/internal/IGXMLScanner2.cpp b/src/xercesc/internal/IGXMLScanner2.cpp
index 54d449286..22251cdfd 100644
--- a/src/xercesc/internal/IGXMLScanner2.cpp
+++ b/src/xercesc/internal/IGXMLScanner2.cpp
@@ -83,8 +83,15 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
     // know what's best.  REVISIT:  don't modify grammar at all; eliminate
     // this step...
     ComplexTypeInfo *currType = 0;
+    DatatypeValidator *currDV = 0;
     if(fGrammar->getGrammarType() == Grammar::SchemaGrammarType && fValidate)
+    {
         currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
+        if (!currType) {
+            currDV = ((SchemaValidator*)fValidator)->getCurrentDatatypeValidator();
+        }
+    }
+
     const bool hasDefs = (currType && fValidate)
             ? currType->resetDefs()
             : elemDecl->resetDefs();
@@ -199,7 +206,7 @@ IGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     attDef = currType->getAttDef(suffPtr, uriId);
                     attWildCard = currType->getAttWildCard();
                 }
-                else { // check explicitly-set wildcard
+                else if (!currDV) { // check explicitly-set wildcard
                     attWildCard = ((SchemaElementDecl*)elemDecl)->getAttWildCard();
                 }
 
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index 4b5494022..8ded13e24 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -2084,9 +2084,17 @@ 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 = (fValidate)
-                ?((SchemaValidator*)fValidator)->getCurrentTypeInfo()
-                :0;
+    DatatypeValidator *currDV = 0;
+    ComplexTypeInfo *currType = 0;
+
+    if (fValidate)
+    {
+        currType = ((SchemaValidator*)fValidator)->getCurrentTypeInfo();
+        if (!currType) {
+            currDV = ((SchemaValidator*)fValidator)->getCurrentDatatypeValidator();
+        }
+    }
+
     const bool hasDefs = (currType && fValidate) 
             ? currType->resetDefs()
             : elemDecl->resetDefs();
@@ -2191,7 +2199,7 @@ SGXMLScanner::buildAttList(const  RefVectorOf<KVStringPair>&  providedAttrs
                     attDef = currType->getAttDef(suffPtr, uriId);
                     attWildCard = currType->getAttWildCard();
                 }
-                else { // check explicitly-set wildcard
+                else if (!currDV) { // check explicitly-set wildcard
                     attWildCard = ((SchemaElementDecl*)elemDecl)->getAttWildCard();
                 }
 
-- 
GitLab