applied patch from Rob Richards for xml:space and xml:lang handling with
* parser.c include/libxml/xmlerror.h: applied patch from Rob Richards
for xml:space and xml:lang handling with SAX2 api.
Daniel
diff --git a/ChangeLog b/ChangeLog
index d50b199..beef272 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jun 9 00:33:50 CEST 2005 Daniel Veillard <daniel@veillard.com>
+
+ * parser.c include/libxml/xmlerror.h: applied patch from Rob Richards
+ for xml:space and xml:lang handling with SAX2 api.
+
Wed Jun 8 19:41:38 CEST 2005 Daniel Veillard <daniel@veillard.com>
* globals.c: applied patch from Morten Welinder, closing bug #306901
diff --git a/include/libxml/xmlerror.h b/include/libxml/xmlerror.h
index 540a51e..76660ac 100644
--- a/include/libxml/xmlerror.h
+++ b/include/libxml/xmlerror.h
@@ -195,6 +195,7 @@
XML_WAR_NS_URI, /* 99 */
XML_WAR_NS_URI_RELATIVE, /* 100 */
XML_ERR_MISSING_ENCODING, /* 101 */
+ XML_WAR_SPACE_VALUE, /* 102 */
XML_NS_ERR_XML_NAMESPACE = 200,
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
XML_NS_ERR_QNAME, /* 202 */
diff --git a/parser.c b/parser.c
index 767d573..b0d9f68 100644
--- a/parser.c
+++ b/parser.c
@@ -6747,9 +6747,9 @@
else if (xmlStrEqual(val, BAD_CAST "preserve"))
*(ctxt->space) = 1;
else {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
+ xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
- val);
+ val, NULL);
}
}
@@ -7414,7 +7414,7 @@
const xmlChar **prefix, xmlChar **value,
int *len, int *alloc) {
const xmlChar *name;
- xmlChar *val;
+ xmlChar *val, *internal_val = NULL;
int normalize = 0;
*value = NULL;
@@ -7452,33 +7452,40 @@
return(NULL);
}
- /*
- * Check that xml:lang conforms to the specification
- * No more registered as an error, just generate a warning now
- * since this was deprecated in XML second edition
- */
- if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "xml:lang"))) {
- if (!xmlCheckLanguageID(val)) {
- xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
- "Malformed value for xml:lang : %s\n",
- val, NULL);
- }
- }
+ if (*prefix == ctxt->str_xml) {
+ /*
+ * Check that xml:lang conforms to the specification
+ * No more registered as an error, just generate a warning now
+ * since this was deprecated in XML second edition
+ */
+ if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
+ internal_val = xmlStrndup(val, *len);
+ if (!xmlCheckLanguageID(internal_val)) {
+ xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
+ "Malformed value for xml:lang : %s\n",
+ internal_val, NULL);
+ }
+ }
- /*
- * Check that xml:space conforms to the specification
- */
- if (xmlStrEqual(name, BAD_CAST "xml:space")) {
- if (xmlStrEqual(val, BAD_CAST "default"))
- *(ctxt->space) = 0;
- else if (xmlStrEqual(val, BAD_CAST "preserve"))
- *(ctxt->space) = 1;
- else {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
+ /*
+ * Check that xml:space conforms to the specification
+ */
+ if (xmlStrEqual(name, BAD_CAST "space")) {
+ internal_val = xmlStrndup(val, *len);
+ if (xmlStrEqual(internal_val, BAD_CAST "default"))
+ *(ctxt->space) = 0;
+ else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
+ *(ctxt->space) = 1;
+ else {
+ xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
- val);
+ internal_val, NULL);
+ }
+ }
+ if (internal_val) {
+ xmlFree(internal_val);
+ }
}
- }
*value = val;
return(name);