aboutsummaryrefslogtreecommitdiffstats
path: root/valid.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2002-02-18 18:31:38 +0000
committerDaniel Veillard <veillard@src.gnome.org>2002-02-18 18:31:38 +0000
commit8ab0f58f7d302e33bae18da516ca9aad6143d691 (patch)
tree11aa352f3c3d8e410baf496cc874661d9cfc7556 /valid.c
parent55253e21f0f41f03afb4842f560a852658077a89 (diff)
downloadandroid_external_libxml2-8ab0f58f7d302e33bae18da516ca9aad6143d691.tar.gz
android_external_libxml2-8ab0f58f7d302e33bae18da516ca9aad6143d691.tar.bz2
android_external_libxml2-8ab0f58f7d302e33bae18da516ca9aad6143d691.zip
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
Diffstat (limited to 'valid.c')
-rw-r--r--valid.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/valid.c b/valid.c
index 32357551..ba1ffdf6 100644
--- a/valid.c
+++ b/valid.c
@@ -4789,8 +4789,29 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
}
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);
}