mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
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:
@ -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>
|
Tue Oct 15 12:41:01 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* README: updated the contact informations
|
* README: updated the contact informations
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/choice_1.xml validates
|
||||||
|
@ -5,5 +5,3 @@ Type of choice 3 : ./test/schemas/choice_2.xsd:6 :elements
|
|||||||
Building content model for doc
|
Building content model for doc
|
||||||
xmlSchemaValidateCallback: b, b, b
|
xmlSchemaValidateCallback: b, b, b
|
||||||
Element doc content check succeeded
|
Element doc content check succeeded
|
||||||
(nil) : Freed()
|
|
||||||
xmlMallocBreakpoint reached on block 0
|
|
||||||
|
1
result/schemas/list0_0_0
Normal file
1
result/schemas/list0_0_0
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_0.xml validates
|
9
result/schemas/list0_0_0.err
Normal file
9
result/schemas/list0_0_0.err
Normal 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
1
result/schemas/list0_0_1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_1.xml fails to validate
|
6
result/schemas/list0_0_1.err
Normal file
6
result/schemas/list0_0_1.err
Normal 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
1
result/schemas/list0_0_2
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_2.xml validates
|
7
result/schemas/list0_0_2.err
Normal file
7
result/schemas/list0_0_2.err
Normal 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
1
result/schemas/list0_1_0
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_0.xml fails to validate
|
8
result/schemas/list0_1_0.err
Normal file
8
result/schemas/list0_1_0.err
Normal 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
1
result/schemas/list0_1_1
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_1.xml fails to validate
|
6
result/schemas/list0_1_1.err
Normal file
6
result/schemas/list0_1_1.err
Normal 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
1
result/schemas/list0_1_2
Normal file
@ -0,0 +1 @@
|
|||||||
|
./test/schemas/list0_2.xml validates
|
7
result/schemas/list0_1_2.err
Normal file
7
result/schemas/list0_1_2.err
Normal 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
6
test/schemas/list0_0.xml
Normal 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
13
test/schemas/list0_0.xsd
Normal 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
3
test/schemas/list0_1.xml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<test>
|
||||||
|
<string>hello world</string>
|
||||||
|
</test>
|
13
test/schemas/list0_1.xsd
Normal file
13
test/schemas/list0_1.xsd
Normal 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
4
test/schemas/list0_2.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<test>
|
||||||
|
<string>hello world</string>
|
||||||
|
<string>hello world</string>
|
||||||
|
</test>
|
@ -2335,8 +2335,10 @@ xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
|
|||||||
if (exec->inputStack != NULL) {
|
if (exec->inputStack != NULL) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0;i < exec->inputStackNr;i++)
|
for (i = 0;i < exec->inputStackNr;i++) {
|
||||||
xmlFree(exec->inputStack[i].value);
|
if (exec->inputStack[i].value != NULL)
|
||||||
|
xmlFree(exec->inputStack[i].value);
|
||||||
|
}
|
||||||
xmlFree(exec->inputStack);
|
xmlFree(exec->inputStack);
|
||||||
}
|
}
|
||||||
xmlFree(exec);
|
xmlFree(exec);
|
||||||
|
77
xmlschemas.c
77
xmlschemas.c
@ -304,6 +304,8 @@ xmlSchemaFreeElement(xmlSchemaElementPtr elem)
|
|||||||
xmlFree((xmlChar *) elem->ref);
|
xmlFree((xmlChar *) elem->ref);
|
||||||
if (elem->refNs != NULL)
|
if (elem->refNs != NULL)
|
||||||
xmlFree((xmlChar *) elem->refNs);
|
xmlFree((xmlChar *) elem->refNs);
|
||||||
|
if (elem->annot != NULL)
|
||||||
|
xmlSchemaFreeAnnot(elem->annot);
|
||||||
if (elem->contModel != NULL)
|
if (elem->contModel != NULL)
|
||||||
xmlRegFreeRegexp(elem->contModel);
|
xmlRegFreeRegexp(elem->contModel);
|
||||||
xmlFree(elem);
|
xmlFree(elem);
|
||||||
@ -351,7 +353,7 @@ xmlSchemaFreeType(xmlSchemaTypePtr type)
|
|||||||
if (type->baseNs != NULL)
|
if (type->baseNs != NULL)
|
||||||
xmlFree((xmlChar *) type->baseNs);
|
xmlFree((xmlChar *) type->baseNs);
|
||||||
if (type->annot != NULL)
|
if (type->annot != NULL)
|
||||||
xmlFree((xmlChar *) type->annot);
|
xmlSchemaFreeAnnot(type->annot);
|
||||||
if (type->facets != NULL) {
|
if (type->facets != NULL) {
|
||||||
xmlSchemaFacetPtr facet, next;
|
xmlSchemaFacetPtr facet, next;
|
||||||
|
|
||||||
@ -3099,6 +3101,57 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type,
|
|||||||
/* TODO : handle the namespace too */
|
/* TODO : handle the namespace too */
|
||||||
xmlAutomataStatePtr oldstate = ctxt->state;
|
xmlAutomataStatePtr oldstate = ctxt->state;
|
||||||
if (elem->maxOccurs >= UNBOUNDED) {
|
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) {
|
if (elem->refDecl != NULL) {
|
||||||
xmlSchemaBuildAContentModel(
|
xmlSchemaBuildAContentModel(
|
||||||
(xmlSchemaTypePtr) elem->refDecl,
|
(xmlSchemaTypePtr) elem->refDecl,
|
||||||
@ -3107,22 +3160,12 @@ xmlSchemaBuildAContentModel(xmlSchemaTypePtr type,
|
|||||||
ctxt->state = xmlAutomataNewTransition(ctxt->am,
|
ctxt->state = xmlAutomataNewTransition(ctxt->am,
|
||||||
ctxt->state, NULL, elem->name, type);
|
ctxt->state, NULL, elem->name, type);
|
||||||
}
|
}
|
||||||
xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldstate);
|
tmp = ctxt->state;
|
||||||
if (elem->minOccurs == 0) {
|
xmlAutomataNewCountedTrans(ctxt->am, tmp, oldstate,
|
||||||
/* basically an elem* */
|
counter);
|
||||||
xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
|
ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, tmp,
|
||||||
}
|
NULL, counter);
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (elem->refDecl != NULL) {
|
if (elem->refDecl != NULL) {
|
||||||
xmlSchemaBuildAContentModel(
|
xmlSchemaBuildAContentModel(
|
||||||
|
Reference in New Issue
Block a user