fixed the validation of sequences content model when some of the blocks

* 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
Daniel
This commit is contained in:
Daniel Veillard 2002-10-16 14:08:14 +00:00
parent a2e8c5ce8b
commit 3237023d6a
22 changed files with 161 additions and 21 deletions

View File

@ -1,3 +1,11 @@
Wed Oct 16 16:05:38 CEST 2002 Daniel Veillard <daniel@veillard.com>
* 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 <daniel@veillard.com>
* README: updated the contact informations

View File

@ -0,0 +1 @@
./test/schemas/choice_1.xml validates

View File

@ -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

1
result/schemas/list0_0_0 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_0.xml validates

View File

@ -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

1
result/schemas/list0_0_1 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_1.xml fails to validate

View File

@ -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

1
result/schemas/list0_0_2 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_2.xml validates

View File

@ -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

1
result/schemas/list0_1_0 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_0.xml fails to validate

View File

@ -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

1
result/schemas/list0_1_1 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_1.xml fails to validate

View File

@ -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

1
result/schemas/list0_1_2 Normal file
View File

@ -0,0 +1 @@
./test/schemas/list0_2.xml validates

View File

@ -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

6
test/schemas/list0_0.xml Normal file
View File

@ -0,0 +1,6 @@
<test>
<string>hello world</string>
<string>hello world</string>
<string>hello world</string>
<string>hello world</string>
</test>

13
test/schemas/list0_0.xsd Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="test">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="string" type="xs:string" minOccurs="2" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

3
test/schemas/list0_1.xml Normal file
View File

@ -0,0 +1,3 @@
<test>
<string>hello world</string>
</test>

13
test/schemas/list0_1.xsd Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="test">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="string" type="xs:string" minOccurs="2" maxOccurs="3"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

4
test/schemas/list0_2.xml Normal file
View File

@ -0,0 +1,4 @@
<test>
<string>hello world</string>
<string>hello world</string>
</test>

View File

@ -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);

View File

@ -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(