From bd56c44349d9e14ed54e77b2706d0f92d1a1f994 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Wed, 12 Aug 2009 15:39:23 +0200 Subject: [PATCH] 571271 fix semantic of xsd:all with minOccurs=0 * xmlschemas.c: apparently we though it allowed any of the sub elements to be missing, and probably not what's expected from the spec, though it used to forbid it c.f.: http://lists.xml.org/archives/xml-dev/200109/msg00512.html asking HT for confirmation but it's likely that we were wrong on the semantic * result/schemas/all_1_[367]*: this changes the output of soem of our internal regression tests --- result/schemas/all_1_3 | 2 +- result/schemas/all_1_3.err | 1 + result/schemas/all_1_6 | 2 +- result/schemas/all_1_6.err | 1 + result/schemas/all_1_7 | 2 +- result/schemas/all_1_7.err | 1 + xmlschemas.c | 14 +++++++++----- 7 files changed, 15 insertions(+), 8 deletions(-) diff --git a/result/schemas/all_1_3 b/result/schemas/all_1_3 index 8186e826..55a2a4da 100644 --- a/result/schemas/all_1_3 +++ b/result/schemas/all_1_3 @@ -1 +1 @@ -./test/schemas/all_3.xml validates +./test/schemas/all_3.xml fails to validate diff --git a/result/schemas/all_1_3.err b/result/schemas/all_1_3.err index e69de29b..6933fb7b 100644 --- a/result/schemas/all_1_3.err +++ b/result/schemas/all_1_3.err @@ -0,0 +1 @@ +./test/schemas/all_3.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ). diff --git a/result/schemas/all_1_6 b/result/schemas/all_1_6 index d4a95948..c3705c75 100644 --- a/result/schemas/all_1_6 +++ b/result/schemas/all_1_6 @@ -1 +1 @@ -./test/schemas/all_6.xml validates +./test/schemas/all_6.xml fails to validate diff --git a/result/schemas/all_1_6.err b/result/schemas/all_1_6.err index e69de29b..c31d91b8 100644 --- a/result/schemas/all_1_6.err +++ b/result/schemas/all_1_6.err @@ -0,0 +1 @@ +./test/schemas/all_6.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is one of ( b, c ). diff --git a/result/schemas/all_1_7 b/result/schemas/all_1_7 index 6ad4fc60..d144d2de 100644 --- a/result/schemas/all_1_7 +++ b/result/schemas/all_1_7 @@ -1 +1 @@ -./test/schemas/all_7.xml validates +./test/schemas/all_7.xml fails to validate diff --git a/result/schemas/all_1_7.err b/result/schemas/all_1_7.err index e69de29b..d5c54287 100644 --- a/result/schemas/all_1_7.err +++ b/result/schemas/all_1_7.err @@ -0,0 +1 @@ +./test/schemas/all_7.xml:1: element doc: Schemas validity error : Element 'doc': Missing child element(s). Expected is ( c ). diff --git a/xmlschemas.c b/xmlschemas.c index d3fe98a4..96d55b82 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -12966,17 +12966,19 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, break; } case XML_SCHEMA_TYPE_ALL:{ - xmlAutomataStatePtr start; + xmlAutomataStatePtr start, tmp; xmlSchemaParticlePtr sub; xmlSchemaElementPtr elemDecl; - int lax; sub = (xmlSchemaParticlePtr) particle->children->children; if (sub == NULL) break; start = pctxt->state; + tmp = xmlAutomataNewState(pctxt->am); + xmlAutomataNewEpsilon(pctxt->am, pctxt->state, tmp); + pctxt->state = tmp; while (sub != NULL) { - pctxt->state = start; + pctxt->state = tmp; elemDecl = (xmlSchemaElementPtr) sub->children; if (elemDecl == NULL) { @@ -13024,9 +13026,11 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt, } sub = (xmlSchemaParticlePtr) sub->next; } - lax = particle->minOccurs == 0; pctxt->state = - xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, lax); + xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, 0); + if (particle->minOccurs == 0) { + xmlAutomataNewEpsilon(pctxt->am, start, pctxt->state); + } break; } case XML_SCHEMA_TYPE_GROUP: