starting to cleanup some of the problems exposed by the W3C/NIST
* SAX2.c parser.c valid.c: starting to cleanup some of the
problems exposed by the W3C/NIST regression suite.
* result/ent7.sax result/xml2.sax: small fixes.
Daniel
diff --git a/ChangeLog b/ChangeLog
index 18bbb07..b1c20f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Sep 15 14:54:42 CEST 2003 Daniel Veillard <daniel@veillard.com>
+
+ * SAX2.c parser.c valid.c: starting to cleanup some of the
+ problems exposed by the W3C/NIST regression suite.
+ * result/ent7.sax result/xml2.sax: small fixes.
+
Mon Sep 15 11:46:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: more parser error factoring
diff --git a/SAX2.c b/SAX2.c
index 4707d02..00fdcb5 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -1596,9 +1596,9 @@
/**
* xmlSAX2AttributeNs:
* @ctx: the user data (XML parser context)
- * @localname: the local name of the element
- * @prefix: the element namespace prefix if available
- * @URI: the element namespace name if available
+ * @localname: the local name of the attribute
+ * @prefix: the attribute namespace prefix if available
+ * @URI: the attribute namespace name if available
* @value: Start of the attribute value
* @valueend: end of the attribute value
*
@@ -1618,11 +1618,6 @@
xmlNsPtr namespace = NULL;
xmlChar *dup = NULL;
-#if 0
- TODO, check taht CDATA normalization is done at the
- parser level !!!!!
-#endif
-
/*
* Note: if prefix == NULL, the attribute is not in the default namespace
*/
@@ -1662,31 +1657,50 @@
if (!ctxt->replaceEntities) {
dup = xmlSAX2DecodeAttrEntities(ctxt, value, valueend);
if (dup == NULL) {
- /*
- * cheaper to finally allocate here than duplicate
- * entry points in the full validation code
- */
- dup = xmlStrndup(value, valueend - value);
+ if (*valueend == 0) {
+ ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
+ ctxt->myDoc, ctxt->node, ret, value);
+ } else {
+ /*
+ * That should already be normalized.
+ * cheaper to finally allocate here than duplicate
+ * entry points in the full validation code
+ */
+ dup = xmlStrndup(value, valueend - value);
- ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
- ctxt->myDoc, ctxt->node, ret, dup);
+ ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
+ ctxt->myDoc, ctxt->node, ret, dup);
+ }
} else {
-#if 0
- TODO
- xmlChar *nvalnorm;
-
- /*
- * Do the last stage of the attribute normalization
+ /*
+ * dup now contains a string of the flattened attribute
+ * content with entities substitued. Check if we need to
+ * apply an extra layer of normalization.
* It need to be done twice ... it's an extra burden related
* to the ability to keep references in attributes
*/
- nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc,
- ctxt->node, fullname, dup);
- if (nvalnorm != NULL) {
- xmlFree(dup);
- dup = nvalnorm;
+ if (ctxt->attsSpecial != NULL) {
+ xmlChar *nvalnorm;
+ xmlChar fn[50];
+ xmlChar *fullname;
+
+ fullname = xmlBuildQName(localname, prefix, fn, 50);
+ if (fullname != NULL) {
+ ctxt->vctxt.valid = 1;
+ nvalnorm = xmlValidCtxtNormalizeAttributeValue(
+ &ctxt->vctxt, ctxt->myDoc,
+ ctxt->node, fullname, dup);
+ if (ctxt->vctxt.valid != 1)
+ ctxt->valid = 0;
+
+ if ((fullname != fn) && (fullname != localname))
+ xmlFree(fullname);
+ if (nvalnorm != NULL) {
+ xmlFree(dup);
+ dup = nvalnorm;
+ }
+ }
}
-#endif
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, dup);
@@ -2221,7 +2235,7 @@
}
}
-static xmlSAX2DefaultVersionValue = 2;
+static int xmlSAX2DefaultVersionValue = 2;
/**
* xmlSAXDefaultVersion:
diff --git a/parser.c b/parser.c
index 1154204..944a656 100644
--- a/parser.c
+++ b/parser.c
@@ -3024,10 +3024,10 @@
(c != '<')) {
if (c == 0) break;
if (c == '&') {
+ in_space = 0;
if (NXT(1) == '#') {
int val = xmlParseCharRef(ctxt);
- in_space = 0;
if (val == '&') {
if (ctxt->replaceEntities) {
if (len > buf_size - 10) {
@@ -3071,7 +3071,6 @@
} else {
buf[len++] = ent->content[0];
}
- in_space = 0;
} else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) {
xmlChar *rep;
diff --git a/result/ent7.sax b/result/ent7.sax
index 0d5befa..4039597 100644
--- a/result/ent7.sax
+++ b/result/ent7.sax
@@ -1,4 +1,3 @@
-xmlSAXUserParseFile returned error 27
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(item, , )
diff --git a/result/xml2.sax b/result/xml2.sax
index e848473..04d7089 100644
--- a/result/xml2.sax
+++ b/result/xml2.sax
@@ -1,4 +1,3 @@
-xmlSAXUserParseFile returned error 27
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(test, , )
diff --git a/valid.c b/valid.c
index 36d1a35..470f912 100644
--- a/valid.c
+++ b/valid.c
@@ -3319,17 +3319,10 @@
xmlEntityPtr ent;
ent = xmlGetDocEntity(doc, value);
+ /* yeah it's a bit messy... */
if ((ent == NULL) && (doc->standalone == 1)) {
doc->standalone = 0;
ent = xmlGetDocEntity(doc, value);
- if (ent != NULL) {
- VERROR(ctxt->userData,
-"standalone problem: attribute %s reference entity \"%s\" in external subset\n",
- name, value);
- /* WAIT to get answer from the Core WG on this
- ret = 0;
- */
- }
}
if (ent == NULL) {
VERROR(ctxt->userData,