diff --git a/ChangeLog b/ChangeLog index 99370efd..0b493062 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Oct 16 16:05:38 CEST 2002 Daniel Veillard + + * xmlregexp.c xmlschemas.c: fixed the validation of sequences + content model when some of the blocks have min or max, and a couple + of bugs found in the process. + * result/schemas/list0* test/schemas/list0*: added some specific + regression tests + Tue Oct 15 12:41:01 CEST 2002 Daniel Veillard * README: updated the contact informations diff --git a/result/schemas/choice_2_1 b/result/schemas/choice_2_1 index e69de29b..e4338ded 100644 --- a/result/schemas/choice_2_1 +++ b/result/schemas/choice_2_1 @@ -0,0 +1 @@ +./test/schemas/choice_1.xml validates diff --git a/result/schemas/choice_2_1.err b/result/schemas/choice_2_1.err index 151657fa..9a6f08f7 100644 --- a/result/schemas/choice_2_1.err +++ b/result/schemas/choice_2_1.err @@ -5,5 +5,3 @@ Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements Building content model for doc xmlSchemaValidateCallback: b, b, b Element doc content check succeeded -(nil) : Freed() -xmlMallocBreakpoint reached on block 0 diff --git a/result/schemas/list0_0_0 b/result/schemas/list0_0_0 new file mode 100644 index 00000000..37a2cdcb --- /dev/null +++ b/result/schemas/list0_0_0 @@ -0,0 +1 @@ +./test/schemas/list0_0.xml validates diff --git a/result/schemas/list0_0_0.err b/result/schemas/list0_0_0.err new file mode 100644 index 00000000..2ba05329 --- /dev/null +++ b/result/schemas/list0_0_0.err @@ -0,0 +1,9 @@ +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_0.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +Element test content check succeeded diff --git a/result/schemas/list0_0_1 b/result/schemas/list0_0_1 new file mode 100644 index 00000000..da757f63 --- /dev/null +++ b/result/schemas/list0_0_1 @@ -0,0 +1 @@ +./test/schemas/list0_1.xml fails to validate diff --git a/result/schemas/list0_0_1.err b/result/schemas/list0_0_1.err new file mode 100644 index 00000000..1d47a5a5 --- /dev/null +++ b/result/schemas/list0_0_1.err @@ -0,0 +1,6 @@ +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_0.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +Element test content check failed diff --git a/result/schemas/list0_0_2 b/result/schemas/list0_0_2 new file mode 100644 index 00000000..0ec62373 --- /dev/null +++ b/result/schemas/list0_0_2 @@ -0,0 +1 @@ +./test/schemas/list0_2.xml validates diff --git a/result/schemas/list0_0_2.err b/result/schemas/list0_0_2.err new file mode 100644 index 00000000..00851e14 --- /dev/null +++ b/result/schemas/list0_0_2.err @@ -0,0 +1,7 @@ +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_0.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_0.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +Element test content check succeeded diff --git a/result/schemas/list0_1_0 b/result/schemas/list0_1_0 new file mode 100644 index 00000000..2cf98061 --- /dev/null +++ b/result/schemas/list0_1_0 @@ -0,0 +1 @@ +./test/schemas/list0_0.xml fails to validate diff --git a/result/schemas/list0_1_0.err b/result/schemas/list0_1_0.err new file mode 100644 index 00000000..d8d80d8b --- /dev/null +++ b/result/schemas/list0_1_0.err @@ -0,0 +1,8 @@ +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_1.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +Element test content check failed diff --git a/result/schemas/list0_1_1 b/result/schemas/list0_1_1 new file mode 100644 index 00000000..da757f63 --- /dev/null +++ b/result/schemas/list0_1_1 @@ -0,0 +1 @@ +./test/schemas/list0_1.xml fails to validate diff --git a/result/schemas/list0_1_1.err b/result/schemas/list0_1_1.err new file mode 100644 index 00000000..256cd3e8 --- /dev/null +++ b/result/schemas/list0_1_1.err @@ -0,0 +1,6 @@ +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_1.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +Element test content check failed diff --git a/result/schemas/list0_1_2 b/result/schemas/list0_1_2 new file mode 100644 index 00000000..0ec62373 --- /dev/null +++ b/result/schemas/list0_1_2 @@ -0,0 +1 @@ +./test/schemas/list0_2.xml validates diff --git a/result/schemas/list0_1_2.err b/result/schemas/list0_1_2.err new file mode 100644 index 00000000..97b47e56 --- /dev/null +++ b/result/schemas/list0_1_2.err @@ -0,0 +1,7 @@ +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Type of anontype1 : ./test/schemas/list0_1.xsd:7 :elements +Type of sequence 2 : ./test/schemas/list0_1.xsd:8 :elements +Building content model for test +xmlSchemaValidateCallback: string, string, string +xmlSchemaValidateCallback: string, string, string +Element test content check succeeded diff --git a/test/schemas/list0_0.xml b/test/schemas/list0_0.xml new file mode 100644 index 00000000..a58fe8b5 --- /dev/null +++ b/test/schemas/list0_0.xml @@ -0,0 +1,6 @@ + + hello world + hello world + hello world + hello world + diff --git a/test/schemas/list0_0.xsd b/test/schemas/list0_0.xsd new file mode 100644 index 00000000..33d7d665 --- /dev/null +++ b/test/schemas/list0_0.xsd @@ -0,0 +1,13 @@ + + + + + Comment describing your root element + + + + + + + + diff --git a/test/schemas/list0_1.xml b/test/schemas/list0_1.xml new file mode 100644 index 00000000..8878e5d0 --- /dev/null +++ b/test/schemas/list0_1.xml @@ -0,0 +1,3 @@ + + hello world + diff --git a/test/schemas/list0_1.xsd b/test/schemas/list0_1.xsd new file mode 100644 index 00000000..8966075a --- /dev/null +++ b/test/schemas/list0_1.xsd @@ -0,0 +1,13 @@ + + + + + Comment describing your root element + + + + + + + + diff --git a/test/schemas/list0_2.xml b/test/schemas/list0_2.xml new file mode 100644 index 00000000..e94d4814 --- /dev/null +++ b/test/schemas/list0_2.xml @@ -0,0 +1,4 @@ + + hello world + hello world + diff --git a/xmlregexp.c b/xmlregexp.c index 627da51e..155a2f00 100644 --- a/xmlregexp.c +++ b/xmlregexp.c @@ -2335,8 +2335,10 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) { if (exec->inputStack != NULL) { int i; - for (i = 0;i < exec->inputStackNr;i++) - xmlFree(exec->inputStack[i].value); + for (i = 0;i < exec->inputStackNr;i++) { + if (exec->inputStack[i].value != NULL) + xmlFree(exec->inputStack[i].value); + } xmlFree(exec->inputStack); } xmlFree(exec); diff --git a/xmlschemas.c b/xmlschemas.c index e49a0b0d..721f3263 100644 --- a/xmlschemas.c +++ b/xmlschemas.c @@ -304,6 +304,8 @@ xmlSchemaFreeElement(xmlSchemaElementPtr elem) xmlFree((xmlChar *) elem->ref); if (elem->refNs != NULL) xmlFree((xmlChar *) elem->refNs); + if (elem->annot != NULL) + xmlSchemaFreeAnnot(elem->annot); if (elem->contModel != NULL) xmlRegFreeRegexp(elem->contModel); xmlFree(elem); @@ -351,7 +353,7 @@ xmlSchemaFreeType(xmlSchemaTypePtr type) if (type->baseNs != NULL) xmlFree((xmlChar *) type->baseNs); if (type->annot != NULL) - xmlFree((xmlChar *) type->annot); + xmlSchemaFreeAnnot(type->annot); if (type->facets != NULL) { xmlSchemaFacetPtr facet, next; @@ -3099,6 +3101,57 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type, /* TODO : handle the namespace too */ xmlAutomataStatePtr oldstate = ctxt->state; if (elem->maxOccurs >= UNBOUNDED) { + if (elem->minOccurs > 1) { + xmlAutomataStatePtr tmp; + int counter; + + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, + oldstate, NULL); + oldstate = ctxt->state; + + counter = xmlAutomataNewCounter(ctxt->am, + elem->minOccurs - 1, UNBOUNDED); + + if (elem->refDecl != NULL) { + xmlSchemaBuildAContentModel( + (xmlSchemaTypePtr) elem->refDecl, + ctxt, elem->refDecl->name); + } else { + ctxt->state = xmlAutomataNewTransition(ctxt->am, + ctxt->state, NULL, elem->name, type); + } + tmp = ctxt->state; + xmlAutomataNewCountedTrans(ctxt->am, tmp, oldstate, + counter); + ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, tmp, + NULL, counter); + + } else { + if (elem->refDecl != NULL) { + xmlSchemaBuildAContentModel( + (xmlSchemaTypePtr) elem->refDecl, + ctxt, elem->refDecl->name); + } else { + ctxt->state = xmlAutomataNewTransition(ctxt->am, + ctxt->state, NULL, elem->name, type); + } + xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldstate); + if (elem->minOccurs == 0) { + /* basically an elem* */ + xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); + } + } + } else if ((elem->maxOccurs > 1) || (elem->minOccurs > 1)) { + xmlAutomataStatePtr tmp; + int counter; + + ctxt->state = xmlAutomataNewEpsilon(ctxt->am, + oldstate, NULL); + oldstate = ctxt->state; + + counter = xmlAutomataNewCounter(ctxt->am, + elem->minOccurs - 1, elem->maxOccurs - 1); + if (elem->refDecl != NULL) { xmlSchemaBuildAContentModel( (xmlSchemaTypePtr) elem->refDecl, @@ -3107,22 +3160,12 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type, ctxt->state = xmlAutomataNewTransition(ctxt->am, ctxt->state, NULL, elem->name, type); } - xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldstate); - if (elem->minOccurs == 0) { - /* basically an elem* */ - xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); - } - } else if (elem->maxOccurs > 1) { - if (elem->refDecl != NULL) { - TODO - xmlSchemaBuildAContentModel( - (xmlSchemaTypePtr) elem->refDecl, - ctxt, elem->refDecl->name); - } else { - ctxt->state = xmlAutomataNewCountTrans(ctxt->am, - ctxt->state, NULL, elem->name, - elem->minOccurs, elem->maxOccurs, type); - } + tmp = ctxt->state; + xmlAutomataNewCountedTrans(ctxt->am, tmp, oldstate, + counter); + ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, tmp, + NULL, counter); + } else { if (elem->refDecl != NULL) { xmlSchemaBuildAContentModel(