From 19d568c5a3a0d49973c2ece8d8f5ec9932b4442f Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Thu, 9 Jan 2003 22:34:54 +0000
Subject: [PATCH] [Bug 14955] error validating parser.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174609 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/internal/IGXMLScanner.cpp         |  6 +++
 src/xercesc/internal/SGXMLScanner.cpp         |  6 +++
 .../validators/schema/SchemaValidator.hpp     | 44 +++++++++++++------
 3 files changed, 42 insertions(+), 14 deletions(-)

diff --git a/src/xercesc/internal/IGXMLScanner.cpp b/src/xercesc/internal/IGXMLScanner.cpp
index a94f71538..e34b3460f 100644
--- a/src/xercesc/internal/IGXMLScanner.cpp
+++ b/src/xercesc/internal/IGXMLScanner.cpp
@@ -1012,6 +1012,9 @@ void IGXMLScanner::scanEndTag(bool& gotData)
         // reset xsi:type ComplexTypeInfo
         if (fGrammarType == Grammar::SchemaGrammarType) {
             ((SchemaElementDecl*)topElem->fThisElement)->setXsiComplexTypeInfo(0);
+            if (!isRoot)
+                ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->setXsiComplexTypeInfo(
+                     ((SchemaValidator*)fValidator)->getCurrentTypeInfo());
 
             // call matchers and de-activate context
             int oldCount = fMatcherStack->getMatcherCount();
@@ -2422,6 +2425,9 @@ bool IGXMLScanner::scanStartTagNS(bool& gotData)
 
                 // reset xsi:type ComplexTypeInfo
                 ((SchemaElementDecl*)elemDecl)->setXsiComplexTypeInfo(0);
+                if (!isRoot)
+                    ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->setXsiComplexTypeInfo(
+                         ((SchemaValidator*)fValidator)->getCurrentTypeInfo());
 
                 // call matchers and de-activate context
                 int oldCount = fMatcherStack->getMatcherCount();
diff --git a/src/xercesc/internal/SGXMLScanner.cpp b/src/xercesc/internal/SGXMLScanner.cpp
index 67db8590f..88894f0f3 100644
--- a/src/xercesc/internal/SGXMLScanner.cpp
+++ b/src/xercesc/internal/SGXMLScanner.cpp
@@ -958,6 +958,9 @@ void SGXMLScanner::scanEndTag(bool& gotData)
 
         // reset xsi:type ComplexTypeInfo
         ((SchemaElementDecl*)topElem->fThisElement)->setXsiComplexTypeInfo(0);
+        if (!isRoot)
+            ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->setXsiComplexTypeInfo(
+                 ((SchemaValidator*)fValidator)->getCurrentTypeInfo());
 
         // call matchers and de-activate context
         int oldCount = fMatcherStack->getMatcherCount();
@@ -1532,6 +1535,9 @@ bool SGXMLScanner::scanStartTag(bool& gotData)
 
             // reset xsi:type ComplexTypeInfo
             ((SchemaElementDecl*)elemDecl)->setXsiComplexTypeInfo(0);
+            if (!isRoot)
+                ((SchemaElementDecl*)(fElemStack.topElement()->fThisElement))->setXsiComplexTypeInfo(
+                     ((SchemaValidator*)fValidator)->getCurrentTypeInfo());
 
             // call matchers and de-activate context
             int oldCount = fMatcherStack->getMatcherCount();
diff --git a/src/xercesc/validators/schema/SchemaValidator.hpp b/src/xercesc/validators/schema/SchemaValidator.hpp
index e1d595859..14bde75f8 100644
--- a/src/xercesc/validators/schema/SchemaValidator.hpp
+++ b/src/xercesc/validators/schema/SchemaValidator.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.11  2003/01/09 22:34:54  tng
+ * [Bug 14955] error validating parser.
+ *
  * Revision 1.10  2002/11/07 21:57:37  tng
  * Fix the following Schema Test Failures:
  * 1. Typo when comparing miscFlags with FIXED
@@ -154,20 +157,6 @@ public:
     SchemaValidator(XMLErrorReporter* const errReporter = 0);
     virtual ~SchemaValidator();
 
-    // -----------------------------------------------------------------------
-    //  Setter methods
-    // -----------------------------------------------------------------------
-    void setGrammarResolver(GrammarResolver* grammarResolver);
-
-    void setXsiType(const XMLCh* const        prefix
-      , const XMLCh* const        localPart
-       , const unsigned int        uriId);
-
-    void setNillable(bool isNil);
-    void setErrorReporter(XMLErrorReporter* const errorReporter);
-    void setExitOnFirstFatal(const bool newValue);
-    void setDatatypeBuffer(const XMLCh* const value);
-
     // -----------------------------------------------------------------------
     //  Implementation of the XMLValidator interface
     // -----------------------------------------------------------------------
@@ -224,6 +213,24 @@ public:
     // -----------------------------------------------------------------------
     void normalizeWhiteSpace(DatatypeValidator* dV, const XMLCh* const value, XMLBuffer& toFill);
 
+    // -----------------------------------------------------------------------
+    //  Setter methods
+    // -----------------------------------------------------------------------
+    void setGrammarResolver(GrammarResolver* grammarResolver);
+
+    void setXsiType(const XMLCh* const        prefix
+      , const XMLCh* const        localPart
+       , const unsigned int        uriId);
+
+    void setNillable(bool isNil);
+    void setErrorReporter(XMLErrorReporter* const errorReporter);
+    void setExitOnFirstFatal(const bool newValue);
+    void setDatatypeBuffer(const XMLCh* const value);
+
+    // -----------------------------------------------------------------------
+    //  Getter methods
+    // -----------------------------------------------------------------------
+    ComplexTypeInfo* getCurrentTypeInfo() const;
 
 private:
     // -----------------------------------------------------------------------
@@ -396,6 +403,15 @@ inline void SchemaValidator::setDatatypeBuffer(const XMLCh* const value)
     fDatatypeBuffer.append(value);
 }
 
+// ---------------------------------------------------------------------------
+//  SchemaValidator: Getter methods
+// ---------------------------------------------------------------------------
+inline ComplexTypeInfo* SchemaValidator::getCurrentTypeInfo() const {
+    if (fTypeStack->empty())
+        return 0;
+    return fTypeStack->peek();
+}
+
 // ---------------------------------------------------------------------------
 //  Virtual interface
 // ---------------------------------------------------------------------------
-- 
GitLab