diff --git a/ChangeLog b/ChangeLog index a754b2e2..97663bf7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Apr 19 13:16:23 CEST 2006 Kasimier Buchcik + + * xmlschemas.c test/schemas/restriction-enum-1* + result/schemas/restriction-enum-1*: Fixed incorrect + validation of restricted enumerations. Added related + regression tests. + Thu Apr 13 09:47:25 CEST 2006 Daniel Veillard * xmlschemas.c: fixing a deallocation problem in xmlSchemaAddSchemaDoc() diff --git a/result/schemas/restriction-enum-1_1_0 b/result/schemas/restriction-enum-1_1_0 new file mode 100644 index 00000000..68e26cfb --- /dev/null +++ b/result/schemas/restriction-enum-1_1_0 @@ -0,0 +1 @@ +./test/schemas/restriction-enum-1_0.xml fails to validate diff --git a/result/schemas/restriction-enum-1_1_0.err b/result/schemas/restriction-enum-1_1_0.err new file mode 100644 index 00000000..086d2deb --- /dev/null +++ b/result/schemas/restriction-enum-1_1_0.err @@ -0,0 +1,2 @@ +./test/schemas/restriction-enum-1_0.xml:7: element foo: Schemas validity error : Element 'foo': [facet 'enumeration'] The value 'c' is not an element of the set {'a', 'b', 'd'}. +./test/schemas/restriction-enum-1_0.xml:7: element foo: Schemas validity error : Element 'foo': 'c' is not a valid value of the atomic type 'barType'. diff --git a/test/schemas/restriction-enum-1_0.xml b/test/schemas/restriction-enum-1_0.xml new file mode 100644 index 00000000..9bdb4a36 --- /dev/null +++ b/test/schemas/restriction-enum-1_0.xml @@ -0,0 +1,7 @@ + + +c diff --git a/test/schemas/restriction-enum-1_1.xsd b/test/schemas/restriction-enum-1_1.xsd new file mode 100644 index 00000000..69e353da --- /dev/null +++ b/test/schemas/restriction-enum-1_1.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/xmlschemas.c b/xmlschemas.c index 3fd72201..453a31cd 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -578,7 +578,7 @@ struct _xmlSchemaConstructionCtxt { 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 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, xmlSchemaFacetPtr facet; xmlSchemaWhitespaceValueType ws; xmlChar *value = NULL; - int res; + int res, found = 0; if (*buf != NULL) xmlFree(*buf); @@ -1788,6 +1788,7 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, 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 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, 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 @@ pattern_and_enum: } 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));