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
diff --git a/ChangeLog b/ChangeLog
index b24fb89..0e8928b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Fri May 9 15:34:32 EDT 2003 Daniel Veillard <daniel@veillard.com>
+
+ * 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 <daniel@veillard.com>
* 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 0000000..c3705c7
--- /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 0000000..a95d38a
--- /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 0000000..d144d2d
--- /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 0000000..e741304
--- /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 0000000..d4a9594
--- /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 0000000..a7c9c83
--- /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 0000000..6ad4fc6
--- /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 0000000..d87926e
--- /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 0000000..77066e0
--- /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 0000000..f663b74
--- /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 0000000..cbda1fe
--- /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 0000000..ec5931b
--- /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 0000000..27db643
--- /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 0000000..cc69c7d
--- /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 0000000..8186e82
--- /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 0000000..e28b843
--- /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 0000000..cdd8824
--- /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 0000000..8912da2
--- /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 0000000..f939f65
--- /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 0000000..f663b74
--- /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 0000000..d4a9594
--- /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 0000000..1a8f42f
--- /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 0000000..6ad4fc6
--- /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 0000000..e28b843
--- /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 0000000..630b0df
--- /dev/null
+++ b/test/schemas/all_2.xsd
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="doc">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="a"/>
+ <xsd:element minOccurs="0" name="b"/>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
diff --git a/test/schemas/all_6.xml b/test/schemas/all_6.xml
new file mode 100644
index 0000000..7dd71b1
--- /dev/null
+++ b/test/schemas/all_6.xml
@@ -0,0 +1 @@
+<doc><a/></doc>
diff --git a/test/schemas/all_7.xml b/test/schemas/all_7.xml
new file mode 100644
index 0000000..c011b3f
--- /dev/null
+++ b/test/schemas/all_7.xml
@@ -0,0 +1 @@
+<doc><a/><b/></doc>
diff --git a/xmllint.c b/xmllint.c
index 698170c..46b0373 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -626,6 +626,7 @@
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 @@
endTimer("Compiling the schemas");
}
}
+#endif
/*
* Process all nodes in sequence
@@ -654,7 +656,11 @@
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 @@
progresult = 3;
}
}
+#ifdef LIBXML_SCHEMAS_ENABLED
if (relaxng != NULL) {
if (xmlTextReaderIsValid(reader) != 1) {
printf("%s fails to validate\n", filename);
@@ -675,6 +682,7 @@
printf("%s validates\n", filename);
}
}
+#endif
/*
* Done, cleanup and status
*/
diff --git a/xmlreader.c b/xmlreader.c
index c7ae1c8..4d37165 100644
--- a/xmlreader.c
+++ b/xmlreader.c
@@ -1208,6 +1208,7 @@
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 @@
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
reader->rngValidCtxt = NULL;
}
+#endif
if (reader->ctxt != NULL) {
if (reader->ctxt->myDoc != NULL) {
xmlFreeDoc(reader->ctxt->myDoc);
@@ -2473,6 +2475,7 @@
return(reader->ctxt->myDoc);
}
+#ifdef LIBXML_SCHEMAS_ENABLED
/**
* xmlTextReaderRelaxNGSetSchema:
* @reader: the xmlTextReaderPtr used
@@ -2590,6 +2593,7 @@
reader->validate = XML_TEXTREADER_VALIDATE_RNG;
return(0);
}
+#endif
/************************************************************************
* *
diff --git a/xmlschemas.c b/xmlschemas.c
index bb63970..50dbc74 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -3350,9 +3350,14 @@
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;