Fixed incorrect validation of restricted enumerations. Added related
* xmlschemas.c test/schemas/restriction-enum-1*
result/schemas/restriction-enum-1*: Fixed incorrect
validation of restricted enumerations. Added related
regression tests.
diff --git a/xmlschemas.c b/xmlschemas.c
index 3fd7220..453a31c 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -578,7 +578,7 @@
struct _xmlSchemaParserCtxt {
int type;
- void *errCtxt; /* user specific error context */
+ void *errCtxt; /* user specific error context */
xmlSchemaValidityErrorFunc error; /* the callback in case of errors */
xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */
int err;
@@ -1774,7 +1774,7 @@
xmlSchemaFacetPtr facet;
xmlSchemaWhitespaceValueType ws;
xmlChar *value = NULL;
- int res;
+ int res, found = 0;
if (*buf != NULL)
xmlFree(*buf);
@@ -1788,6 +1788,7 @@
for (facet = type->facets; facet != NULL; facet = facet->next) {
if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
continue;
+ found = 1;
res = xmlSchemaGetCanonValueWhtspExt(facet->val,
ws, &value);
if (res == -1) {
@@ -1810,6 +1811,14 @@
value = NULL;
}
}
+ /*
+ * The enumeration facet of a type restricts the enumeration
+ * facet of the ancestor type; i.e., such restricted enumerations
+ * do not belong to the set of the given type. Thus we break
+ * on the first found enumeration.
+ */
+ if (found)
+ break;
type = type->baseType;
} while ((type != NULL) && (type->type != XML_SCHEMA_TYPE_BASIC));
@@ -23912,6 +23921,14 @@
}
if (ret != 0)
break;
+ /*
+ * Break on the first set of enumerations. Any additional
+ * enumerations which might be existent on the ancestors
+ * of the current type are restricted by this set; thus
+ * *must* *not* be taken into account.
+ */
+ if (found)
+ break;
tmpType = tmpType->baseType;
} while ((tmpType != NULL) &&
(tmpType->type != XML_SCHEMA_TYPE_BASIC));