mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
working on better error reporting of validity errors, especially providing
* error.c valid.c: working on better error reporting of validity errors, especially providing an accurate context. * result/valid/xlink.xml.err result/valid/rss.xml.err: better error reports in those cases. Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
||||
Thu Sep 5 16:19:18 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* error.c valid.c: working on better error reporting of validity
|
||||
errors, especially providing an accurate context.
|
||||
* result/valid/xlink.xml.err result/valid/rss.xml.err: better
|
||||
error reports in those cases.
|
||||
|
||||
Thu Sep 5 13:29:47 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* DOCBparser.c HTMLparser.c c14n.c entities.c list.c
|
||||
|
31
error.c
31
error.c
@ -350,22 +350,34 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
char * str;
|
||||
int len = xmlStrlen((const xmlChar *) msg);
|
||||
static int had_info = 0;
|
||||
int need_context = 0;
|
||||
int need_info = 0;
|
||||
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input->filename == NULL) && (ctxt->inputNr > 1))
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
|
||||
xmlParserPrintFileInfo(input);
|
||||
if ((len > 1) && (msg[len - 2] != ':')) {
|
||||
if (ctxt != NULL) {
|
||||
input = ctxt->input;
|
||||
if ((input->filename == NULL) && (ctxt->inputNr > 1))
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
|
||||
if (had_info == 0) {
|
||||
xmlParserPrintFileInfo(input);
|
||||
}
|
||||
}
|
||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||
need_context = 1;
|
||||
had_info = 0;
|
||||
} else {
|
||||
had_info = 1;
|
||||
}
|
||||
|
||||
xmlGenericError(xmlGenericErrorContext, "validity error: ");
|
||||
XML_GET_VAR_STR(msg, str);
|
||||
xmlGenericError(xmlGenericErrorContext, "%s", str);
|
||||
if (str != NULL)
|
||||
xmlFree(str);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
if ((ctxt != NULL) && (input != NULL)) {
|
||||
xmlParserPrintFileContext(input);
|
||||
}
|
||||
}
|
||||
@ -385,8 +397,9 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
|
||||
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
|
||||
xmlParserInputPtr input = NULL;
|
||||
char * str;
|
||||
int len = xmlStrlen((const xmlChar *) msg);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) {
|
||||
input = ctxt->input;
|
||||
if ((input->filename == NULL) && (ctxt->inputNr > 1))
|
||||
input = ctxt->inputTab[ctxt->inputNr - 2];
|
||||
|
@ -1,3 +1,3 @@
|
||||
./test/valid/rss.xml:177: validity error: Element rss does not carry attribute version
|
||||
./test/valid/rss.xml:172: validity error: Element rss does not carry attribute version
|
||||
</rss>
|
||||
^
|
||||
|
@ -1,6 +1,6 @@
|
||||
./test/valid/xlink.xml:450: validity error: ID dt-arc already defined
|
||||
<p><termdef id="dt-arc" term="Arc">An <term>arc</term> is contained within an
|
||||
^
|
||||
./test/valid/xlink.xml:530: validity error: IDREF attribute def references an unknown ID "dt-xlg"
|
||||
./test/valid/xlink.xml:199: validity error: IDREF attribute def references an unknown ID "dt-xlg"
|
||||
|
||||
^
|
||||
|
31
valid.c
31
valid.c
@ -311,23 +311,27 @@ xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
|
||||
|
||||
#define VECTXT(ctxt, node) \
|
||||
if ((ctxt != NULL) && (ctxt->error != NULL) && \
|
||||
(node != NULL) && (node->type == XML_ELEMENT_NODE)) { \
|
||||
if ((node->doc != NULL) && (node->doc->URL != NULL)) \
|
||||
ctxt->error(ctxt->userData, "%s:%d:", node->doc->URL,\
|
||||
(node != NULL)) { \
|
||||
xmlChar *base = xmlNodeGetBase(NULL,node); \
|
||||
if (base != NULL) { \
|
||||
ctxt->error(ctxt->userData, "%s:%d: ", base, \
|
||||
(int) node->content); \
|
||||
else \
|
||||
ctxt->error(ctxt->userData, ":%d:", \
|
||||
xmlFree(base); \
|
||||
} else \
|
||||
ctxt->error(ctxt->userData, ":%d: ", \
|
||||
(int) node->content); \
|
||||
}
|
||||
|
||||
#define VWCTXT(ctxt, node) \
|
||||
if ((ctxt != NULL) && (ctxt->warning != NULL) && \
|
||||
(node != NULL) && (node->type == XML_ELEMENT_NODE)) { \
|
||||
if ((node->doc != NULL) && (node->doc->URL != NULL)) \
|
||||
ctxt->warning(ctxt->userData, "%s:%d:", node->doc->URL,\
|
||||
(node != NULL)) { \
|
||||
xmlChar *base = xmlNodeGetBase(NULL,node); \
|
||||
if (base != NULL) { \
|
||||
ctxt->warning(ctxt->userData, "%s:%d: ", base, \
|
||||
(int) node->content); \
|
||||
else \
|
||||
ctxt->warning(ctxt->userData, ":%d:", \
|
||||
xmlFree(base); \
|
||||
} else \
|
||||
ctxt->warning(ctxt->userData, ":%d: ", \
|
||||
(int) node->content); \
|
||||
}
|
||||
|
||||
@ -1904,8 +1908,10 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
|
||||
/*
|
||||
* The id is already defined in this DTD.
|
||||
*/
|
||||
if (ctxt != NULL)
|
||||
if (ctxt != NULL) {
|
||||
VECTXT(ctxt, attr->parent);
|
||||
VERROR(ctxt->userData, "ID %s already defined\n", value);
|
||||
}
|
||||
xmlFreeID(ret);
|
||||
return(NULL);
|
||||
}
|
||||
@ -4786,6 +4792,7 @@ xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||
if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) &&
|
||||
(xmlStrEqual(root->name, BAD_CAST "html")))
|
||||
goto name_ok;
|
||||
VECTXT(ctxt, root);
|
||||
VERROR(ctxt->userData,
|
||||
"Not valid: root and DTD name do not match '%s' and '%s'\n",
|
||||
root->name, doc->intSubset->name);
|
||||
@ -4874,6 +4881,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
|
||||
if (attr->atype == XML_ATTRIBUTE_IDREF) {
|
||||
id = xmlGetID(ctxt->doc, name);
|
||||
if (id == NULL) {
|
||||
VECTXT(ctxt, attr->parent);
|
||||
VERROR(ctxt->userData,
|
||||
"IDREF attribute %s references an unknown ID \"%s\"\n",
|
||||
attr->name, name);
|
||||
@ -4895,6 +4903,7 @@ xmlValidateRef(xmlRefPtr ref, xmlValidCtxtPtr ctxt,
|
||||
*cur = 0;
|
||||
id = xmlGetID(ctxt->doc, str);
|
||||
if (id == NULL) {
|
||||
VECTXT(ctxt, attr->parent);
|
||||
VERROR(ctxt->userData,
|
||||
"IDREFS attribute %s references an unknown ID \"%s\"\n",
|
||||
attr->name, str);
|
||||
|
Reference in New Issue
Block a user