From 1d314860ec913abb443ca0390c7e66a69ed61515 Mon Sep 17 00:00:00 2001
From: Alberto Massari <amassari@apache.org>
Date: Fri, 21 Aug 2009 10:36:58 +0000
Subject: [PATCH] When testing for simple type blocked substitutions, allow
 list and unions when base type is anySimpleType

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@806488 13f79535-47bb-0310-9956-ffa450edef68
---
 .../validators/schema/SchemaValidator.cpp     | 28 +++++++++++++------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/xercesc/validators/schema/SchemaValidator.cpp b/src/xercesc/validators/schema/SchemaValidator.cpp
index 20f403163..5d0625ee9 100644
--- a/src/xercesc/validators/schema/SchemaValidator.cpp
+++ b/src/xercesc/validators/schema/SchemaValidator.cpp
@@ -15,6 +15,10 @@
  * limitations under the License.
  */
 
+/*
+ * $Id$
+ */
+
 // ---------------------------------------------------------------------------
 //  Includes
 // ---------------------------------------------------------------------------
@@ -683,15 +687,23 @@ void SchemaValidator::validateElement(const   XMLElementDecl*  elemDef)
                             }
                             else if(fCurrentDatatypeValidator != xsiTypeDV)
                             {
-                                // the type is derived from ancestor
-                                if ((((SchemaElementDecl*)elemDef)->getBlockSet() & SchemaSymbols::XSD_RESTRICTION) != 0) {
-                                    emitError(XMLValid::ElemNoSubforBlock, elemDef->getFullName());
-                                    fErrorOccurred = true;
+                                DatatypeValidator::ValidatorType derivedType=xsiTypeDV->getType();
+                                if((derivedType == DatatypeValidator::List || derivedType == DatatypeValidator::Union) && fCurrentDatatypeValidator==0)
+                                {
+                                    // the substitution is always allowed if the type is list or union and the base type was xs:anySimpleType
                                 }
-                                if (elemDef->hasAttDefs()) {
-                                    // if we have an attribute but xsi:type's type is simple, we have a problem...
-                                    emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName());
-                                    fErrorOccurred = true;
+                                else
+                                {
+                                    // the type is derived from ancestor
+                                    if ((((SchemaElementDecl*)elemDef)->getBlockSet() & SchemaSymbols::XSD_RESTRICTION) != 0) {
+                                        emitError(XMLValid::ElemNoSubforBlock, elemDef->getFullName());
+                                        fErrorOccurred = true;
+                                    }
+                                    if (elemDef->hasAttDefs()) {
+                                        // if we have an attribute but xsi:type's type is simple, we have a problem...
+                                        emitError(XMLValid::NonDerivedXsiType, fXsiType->getRawName(), elemDef->getFullName());
+                                        fErrorOccurred = true;
+                                    }
                                 }
                             }
 
-- 
GitLab