Commit 8ab0f58f authored by Daniel Veillard's avatar Daniel Veillard
Browse files

more work on the conformance suite. Took the step to finally block

* SAX.c parserInternals.c valid.c: more work on the conformance
  suite. Took the step to finally block documents with encoding
  errors. It's a fatal error per the spec, people should have fixed
  their documents by now.
Daniel
parent 55253e21
Mon Feb 18 19:27:32 CET 2002 Daniel Veillard <daniel@veillard.com>
* SAX.c parserInternals.c valid.c: more work on the conformance
suite. Took the step to finally block documents with encoding
errors. It's a fatal error per the spec, people should have fixed
their documents by now.
Mon Feb 18 15:30:14 CET 2002 Daniel Veillard <daniel@veillard.com>
* check-xml-test-suite.py: fixed the test script after some discussion
......
......@@ -640,6 +640,8 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
"SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
name, publicId, systemId, notationName);
#endif
#if 0
Done in xmlValidateDtdFinal now.
if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc) {
int ret;
ret = xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc,
......@@ -649,6 +651,7 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
ctxt->valid = 0;
}
}
#endif
if (ctxt->inSubset == 1) {
ent = xmlAddDocEntity(ctxt->myDoc, name,
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,
......@@ -1220,7 +1223,13 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
* check the document root element for validity
*/
if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
ctxt->valid &= xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
if (chk <= 0)
ctxt->valid = 0;
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
ctxt->vctxt.finishDtd = 1;
}
......
......@@ -1228,6 +1228,7 @@ encoding_error:
ctxt->input->cur[0], ctxt->input->cur[1],
ctxt->input->cur[2], ctxt->input->cur[3]);
}
ctxt->wellFormed = 0;
ctxt->errNo = XML_ERR_INVALID_ENCODING;
ctxt->charset = XML_CHAR_ENCODING_8859_1;
......@@ -1371,6 +1372,7 @@ encoding_error:
ctxt->input->cur[0], ctxt->input->cur[1],
ctxt->input->cur[2], ctxt->input->cur[3]);
}
ctxt->wellFormed = 0;
ctxt->errNo = XML_ERR_INVALID_ENCODING;
ctxt->charset = XML_CHAR_ENCODING_8859_1;
......@@ -1481,6 +1483,7 @@ encoding_error:
ctxt->input->cur[2], ctxt->input->cur[3]);
}
ctxt->errNo = XML_ERR_INVALID_ENCODING;
ctxt->wellFormed = 0;
}
*len = 1;
......
......@@ -4788,9 +4788,30 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
return(ret);
}
static void
xmlValidateNotationCallback(xmlEntityPtr cur, xmlValidCtxtPtr ctxt,
const xmlChar *name ATTRIBUTE_UNUSED) {
if (cur == NULL)
return;
if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
xmlChar *notation = cur->content;
if (cur != NULL) {
int ret;
ret = xmlValidateNotationUse(ctxt, cur->doc, notation);
if (ret != 1) {
ctxt->valid = -1;
}
}
}
}
static void
xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
const xmlChar *name ATTRIBUTE_UNUSED) {
int ret;
if (cur == NULL)
return;
switch (cur->atype) {
......@@ -4806,14 +4827,19 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
case XML_ATTRIBUTE_ENTITIES:
case XML_ATTRIBUTE_NOTATION:
if (cur->defaultValue != NULL) {
ctxt->valid &= xmlValidateAttributeValue2(ctxt, ctxt->doc,
cur->name, cur->atype, cur->defaultValue);
ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name,
cur->atype, cur->defaultValue);
if ((ret == 0) && (ctxt->valid == 1))
ctxt->valid = 0;
}
if (cur->tree != NULL) {
xmlEnumerationPtr tree = cur->tree;
while (tree != NULL) {
ctxt->valid &= xmlValidateAttributeValue2(ctxt, ctxt->doc,
ret = xmlValidateAttributeValue2(ctxt, ctxt->doc,
cur->name, cur->atype, tree->name);
if ((ret == 0) && (ctxt->valid == 1))
ctxt->valid = 0;
tree = tree->next;
}
}
......@@ -4834,29 +4860,35 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
* - check that NOTATION type attributes default or
* possible values matches one of the defined notations.
*
* returns 1 if valid or 0 otherwise
* returns 1 if valid or 0 if invalid and -1 if not well-formed
*/
int
xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
int ret = 1;
xmlDtdPtr dtd;
xmlAttributeTablePtr table;
xmlEntitiesTablePtr entities;
if (doc == NULL) return(0);
if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
return(0);
ctxt->doc = doc;
ctxt->valid = ret;
ctxt->valid = 1;
dtd = doc->intSubset;
if ((dtd != NULL) && (dtd->attributes != NULL)) {
table = (xmlAttributeTablePtr) dtd->attributes;
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
entities = (xmlEntitiesTablePtr) dtd->entities;
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
ctxt);
}
dtd = doc->extSubset;
if ((dtd != NULL) && (dtd->attributes != NULL)) {
table = (xmlAttributeTablePtr) dtd->attributes;
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
entities = (xmlEntitiesTablePtr) dtd->entities;
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
ctxt);
}
return(ctxt->valid);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment