From 37fc84d1555b06cd0600d21115851ec397d34ba2 Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Fri, 9 May 2003 19:38:15 +0000 Subject: [PATCH] fixing bug #104081 with xs:all with an element holding minOccurs="0" added * xmlschemas.c: fixing bug #104081 with xs:all with an element holding minOccurs="0" * test/schemas/all_* result/schemas/all_*: added some regression tests for that bug * xmllint.c xmlreader.c: patches from Joerg Schmitz-Linneweber and Garry Pennington to compile without schemas support. Daniel --- ChangeLog | 9 +++++++++ result/schemas/all_0_6 | 1 + result/schemas/all_0_6.err | 6 ++++++ result/schemas/all_0_7 | 1 + result/schemas/all_0_7.err | 7 +++++++ result/schemas/all_1_6 | 1 + result/schemas/all_1_6.err | 6 ++++++ result/schemas/all_1_7 | 1 + result/schemas/all_1_7.err | 7 +++++++ result/schemas/all_2_0 | 1 + result/schemas/all_2_0.err | 7 +++++++ result/schemas/all_2_1 | 1 + result/schemas/all_2_1.err | 6 ++++++ result/schemas/all_2_2 | 1 + result/schemas/all_2_2.err | 7 +++++++ result/schemas/all_2_3 | 1 + result/schemas/all_2_3.err | 7 +++++++ result/schemas/all_2_4 | 1 + result/schemas/all_2_4.err | 5 +++++ result/schemas/all_2_5 | 1 + result/schemas/all_2_5.err | 7 +++++++ result/schemas/all_2_6 | 1 + result/schemas/all_2_6.err | 6 ++++++ result/schemas/all_2_7 | 1 + result/schemas/all_2_7.err | 7 +++++++ test/schemas/all_2.xsd | 11 +++++++++++ test/schemas/all_6.xml | 1 + test/schemas/all_7.xml | 1 + xmllint.c | 8 ++++++++ xmlreader.c | 4 ++++ xmlschemas.c | 11 ++++++++--- 31 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 result/schemas/all_0_6 create mode 100644 result/schemas/all_0_6.err create mode 100644 result/schemas/all_0_7 create mode 100644 result/schemas/all_0_7.err create mode 100644 result/schemas/all_1_6 create mode 100644 result/schemas/all_1_6.err create mode 100644 result/schemas/all_1_7 create mode 100644 result/schemas/all_1_7.err create mode 100644 result/schemas/all_2_0 create mode 100644 result/schemas/all_2_0.err create mode 100644 result/schemas/all_2_1 create mode 100644 result/schemas/all_2_1.err create mode 100644 result/schemas/all_2_2 create mode 100644 result/schemas/all_2_2.err create mode 100644 result/schemas/all_2_3 create mode 100644 result/schemas/all_2_3.err create mode 100644 result/schemas/all_2_4 create mode 100644 result/schemas/all_2_4.err create mode 100644 result/schemas/all_2_5 create mode 100644 result/schemas/all_2_5.err create mode 100644 result/schemas/all_2_6 create mode 100644 result/schemas/all_2_6.err create mode 100644 result/schemas/all_2_7 create mode 100644 result/schemas/all_2_7.err create mode 100644 test/schemas/all_2.xsd create mode 100644 test/schemas/all_6.xml create mode 100644 test/schemas/all_7.xml diff --git a/ChangeLog b/ChangeLog index b24fb892..0e8928bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri May 9 15:34:32 EDT 2003 Daniel Veillard + + * xmlschemas.c: fixing bug #104081 with xs:all with an element + holding minOccurs="0" + * test/schemas/all_* result/schemas/all_*: added some regression + tests for that bug + * xmllint.c xmlreader.c: patches from Joerg Schmitz-Linneweber and + Garry Pennington to compile without schemas support. + Thu May 1 10:02:35 CEST 2003 Daniel Veillard * tree.c: fixed a problem with xmlUnlinkNode() for DTDs. diff --git a/result/schemas/all_0_6 b/result/schemas/all_0_6 new file mode 100644 index 00000000..c3705c75 --- /dev/null +++ b/result/schemas/all_0_6 @@ -0,0 +1 @@ +./test/schemas/all_6.xml fails to validate diff --git a/result/schemas/all_0_6.err b/result/schemas/all_0_6.err new file mode 100644 index 00000000..a95d38a1 --- /dev/null +++ b/result/schemas/all_0_6.err @@ -0,0 +1,6 @@ +Type of all2 : ./test/schemas/all_0.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_0.xsd:4 :elements +Type of all2 : ./test/schemas/all_0.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/all_0_7 b/result/schemas/all_0_7 new file mode 100644 index 00000000..d144d2de --- /dev/null +++ b/result/schemas/all_0_7 @@ -0,0 +1 @@ +./test/schemas/all_7.xml fails to validate diff --git a/result/schemas/all_0_7.err b/result/schemas/all_0_7.err new file mode 100644 index 00000000..e7413042 --- /dev/null +++ b/result/schemas/all_0_7.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_0.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_0.xsd:4 :elements +Type of all2 : ./test/schemas/all_0.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check failed diff --git a/result/schemas/all_1_6 b/result/schemas/all_1_6 new file mode 100644 index 00000000..d4a95948 --- /dev/null +++ b/result/schemas/all_1_6 @@ -0,0 +1 @@ +./test/schemas/all_6.xml validates diff --git a/result/schemas/all_1_6.err b/result/schemas/all_1_6.err new file mode 100644 index 00000000..a7c9c836 --- /dev/null +++ b/result/schemas/all_1_6.err @@ -0,0 +1,6 @@ +Type of all2 : ./test/schemas/all_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_1.xsd:4 :elements +Type of all2 : ./test/schemas/all_1.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/all_1_7 b/result/schemas/all_1_7 new file mode 100644 index 00000000..6ad4fc60 --- /dev/null +++ b/result/schemas/all_1_7 @@ -0,0 +1 @@ +./test/schemas/all_7.xml validates diff --git a/result/schemas/all_1_7.err b/result/schemas/all_1_7.err new file mode 100644 index 00000000..d87926e3 --- /dev/null +++ b/result/schemas/all_1_7.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_1.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_1.xsd:4 :elements +Type of all2 : ./test/schemas/all_1.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded diff --git a/result/schemas/all_2_0 b/result/schemas/all_2_0 new file mode 100644 index 00000000..77066e03 --- /dev/null +++ b/result/schemas/all_2_0 @@ -0,0 +1 @@ +./test/schemas/all_0.xml fails to validate diff --git a/result/schemas/all_2_0.err b/result/schemas/all_2_0.err new file mode 100644 index 00000000..f663b749 --- /dev/null +++ b/result/schemas/all_2_0.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check failed diff --git a/result/schemas/all_2_1 b/result/schemas/all_2_1 new file mode 100644 index 00000000..cbda1fe8 --- /dev/null +++ b/result/schemas/all_2_1 @@ -0,0 +1 @@ +./test/schemas/all_1.xml fails to validate diff --git a/result/schemas/all_2_1.err b/result/schemas/all_2_1.err new file mode 100644 index 00000000..ec5931b7 --- /dev/null +++ b/result/schemas/all_2_1.err @@ -0,0 +1,6 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: b, b, b +Element doc content check failed diff --git a/result/schemas/all_2_2 b/result/schemas/all_2_2 new file mode 100644 index 00000000..27db6438 --- /dev/null +++ b/result/schemas/all_2_2 @@ -0,0 +1 @@ +./test/schemas/all_2.xml fails to validate diff --git a/result/schemas/all_2_2.err b/result/schemas/all_2_2.err new file mode 100644 index 00000000..cc69c7d0 --- /dev/null +++ b/result/schemas/all_2_2.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: b, b, b +xmlSchemaValidateCallback: a, a, a +Element doc content check failed diff --git a/result/schemas/all_2_3 b/result/schemas/all_2_3 new file mode 100644 index 00000000..8186e826 --- /dev/null +++ b/result/schemas/all_2_3 @@ -0,0 +1 @@ +./test/schemas/all_3.xml validates diff --git a/result/schemas/all_2_3.err b/result/schemas/all_2_3.err new file mode 100644 index 00000000..e28b8438 --- /dev/null +++ b/result/schemas/all_2_3.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded diff --git a/result/schemas/all_2_4 b/result/schemas/all_2_4 new file mode 100644 index 00000000..cdd8824b --- /dev/null +++ b/result/schemas/all_2_4 @@ -0,0 +1 @@ +./test/schemas/all_4.xml fails to validate diff --git a/result/schemas/all_2_4.err b/result/schemas/all_2_4.err new file mode 100644 index 00000000..8912da27 --- /dev/null +++ b/result/schemas/all_2_4.err @@ -0,0 +1,5 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +Element doc content check failed diff --git a/result/schemas/all_2_5 b/result/schemas/all_2_5 new file mode 100644 index 00000000..f939f657 --- /dev/null +++ b/result/schemas/all_2_5 @@ -0,0 +1 @@ +./test/schemas/all_5.xml fails to validate diff --git a/result/schemas/all_2_5.err b/result/schemas/all_2_5.err new file mode 100644 index 00000000..f663b749 --- /dev/null +++ b/result/schemas/all_2_5.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check failed diff --git a/result/schemas/all_2_6 b/result/schemas/all_2_6 new file mode 100644 index 00000000..d4a95948 --- /dev/null +++ b/result/schemas/all_2_6 @@ -0,0 +1 @@ +./test/schemas/all_6.xml validates diff --git a/result/schemas/all_2_6.err b/result/schemas/all_2_6.err new file mode 100644 index 00000000..1a8f42f5 --- /dev/null +++ b/result/schemas/all_2_6.err @@ -0,0 +1,6 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +Element doc content check succeeded diff --git a/result/schemas/all_2_7 b/result/schemas/all_2_7 new file mode 100644 index 00000000..6ad4fc60 --- /dev/null +++ b/result/schemas/all_2_7 @@ -0,0 +1 @@ +./test/schemas/all_7.xml validates diff --git a/result/schemas/all_2_7.err b/result/schemas/all_2_7.err new file mode 100644 index 00000000..e28b8438 --- /dev/null +++ b/result/schemas/all_2_7.err @@ -0,0 +1,7 @@ +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Type of anontype1 : ./test/schemas/all_2.xsd:4 :elements +Type of all2 : ./test/schemas/all_2.xsd:5 :elements +Building content model for doc +xmlSchemaValidateCallback: a, a, a +xmlSchemaValidateCallback: b, b, b +Element doc content check succeeded diff --git a/test/schemas/all_2.xsd b/test/schemas/all_2.xsd new file mode 100644 index 00000000..630b0df3 --- /dev/null +++ b/test/schemas/all_2.xsd @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/test/schemas/all_6.xml b/test/schemas/all_6.xml new file mode 100644 index 00000000..7dd71b10 --- /dev/null +++ b/test/schemas/all_6.xml @@ -0,0 +1 @@ + diff --git a/test/schemas/all_7.xml b/test/schemas/all_7.xml new file mode 100644 index 00000000..c011b3fa --- /dev/null +++ b/test/schemas/all_7.xml @@ -0,0 +1 @@ + diff --git a/xmllint.c b/xmllint.c index 698170c2..46b0373f 100644 --- a/xmllint.c +++ b/xmllint.c @@ -626,6 +626,7 @@ static void streamFile(char *filename) { xmlTextReaderSetParserProp(reader, XML_PARSER_VALIDATE, 1); else xmlTextReaderSetParserProp(reader, XML_PARSER_LOADDTD, 1); +#ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) { if (timing) { startTimer(); @@ -640,6 +641,7 @@ static void streamFile(char *filename) { endTimer("Compiling the schemas"); } } +#endif /* * Process all nodes in sequence @@ -654,7 +656,11 @@ static void streamFile(char *filename) { ret = xmlTextReaderRead(reader); } if (timing) { +#ifdef LIBXML_SCHEMAS_ENABLED if ((valid) || (relaxng != NULL)) +#else + if (valid) +#endif endTimer("Parsing and validating"); else endTimer("Parsing"); @@ -667,6 +673,7 @@ static void streamFile(char *filename) { progresult = 3; } } +#ifdef LIBXML_SCHEMAS_ENABLED if (relaxng != NULL) { if (xmlTextReaderIsValid(reader) != 1) { printf("%s fails to validate\n", filename); @@ -675,6 +682,7 @@ static void streamFile(char *filename) { printf("%s validates\n", filename); } } +#endif /* * Done, cleanup and status */ diff --git a/xmlreader.c b/xmlreader.c index c7ae1c8e..4d371650 100644 --- a/xmlreader.c +++ b/xmlreader.c @@ -1208,6 +1208,7 @@ void xmlFreeTextReader(xmlTextReaderPtr reader) { if (reader == NULL) return; +#ifdef LIBXML_SCHEMAS_ENABLED if (reader->rngSchemas != NULL) { xmlRelaxNGFree(reader->rngSchemas); reader->rngSchemas = NULL; @@ -1216,6 +1217,7 @@ xmlFreeTextReader(xmlTextReaderPtr reader) { xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt); reader->rngValidCtxt = NULL; } +#endif if (reader->ctxt != NULL) { if (reader->ctxt->myDoc != NULL) { xmlFreeDoc(reader->ctxt->myDoc); @@ -2473,6 +2475,7 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) { return(reader->ctxt->myDoc); } +#ifdef LIBXML_SCHEMAS_ENABLED /** * xmlTextReaderRelaxNGSetSchema: * @reader: the xmlTextReaderPtr used @@ -2590,6 +2593,7 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) { reader->validate = XML_TEXTREADER_VALIDATE_RNG; return(0); } +#endif /************************************************************************ * * diff --git a/xmlschemas.c b/xmlschemas.c index bb639709..50dbc740 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -3350,9 +3350,14 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type, elem = (xmlSchemaElementPtr) subtypes; /* TODO : handle the namespace too */ - xmlAutomataNewOnceTrans(ctxt->am, ctxt->state, ctxt->state, - elem->name, elem->minOccurs, elem->maxOccurs, - subtypes); + if ((elem->minOccurs == 1) && (elem->maxOccurs == 1)) { + xmlAutomataNewOnceTrans(ctxt->am, ctxt->state, ctxt->state, + elem->name, 1, 1, subtypes); + } else { + xmlAutomataNewCountTrans(ctxt->am, ctxt->state, ctxt->state, + elem->name, elem->minOccurs, + elem->maxOccurs, subtypes); + } subtypes = subtypes->next; } lax = type->minOccurs == 0;