Added xmlSchemaSetParserStructuredErrors() to the API. Fixed channeling of
* xmlschemas.c include/libxml/xmlschemas.h:
Added xmlSchemaSetParserStructuredErrors() to the API.
Fixed channeling of error relevant information to
subsequent parser/validation contexts.
diff --git a/ChangeLog b/ChangeLog
index d71af09..bb0bc4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Nov 18 18:13:38 CET 2005 Kasimier Buchcik <libxml2-cvs@cazic.net>
+
+ * xmlschemas.c include/libxml/xmlschemas.h:
+ Added xmlSchemaSetParserStructuredErrors() to the API.
+ Fixed channeling of error relevant information to
+ subsequent parser/validation contexts.
+
Thu Nov 17 14:11:43 CET 2005 Daniel Veillard <daniel@veillard.com>
* parserInternals.c: removed unreachable code pointed out by
diff --git a/include/libxml/xmlschemas.h b/include/libxml/xmlschemas.h
index ab47091..15faef5 100644
--- a/include/libxml/xmlschemas.h
+++ b/include/libxml/xmlschemas.h
@@ -113,6 +113,10 @@
xmlSchemaValidityErrorFunc err,
xmlSchemaValidityWarningFunc warn,
void *ctx);
+XMLPUBFUN void XMLCALL
+ xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror,
+ void *ctx);
XMLPUBFUN int XMLCALL
xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaValidityErrorFunc * err,
@@ -140,7 +144,8 @@
void *ctx);
XMLPUBFUN void XMLCALL
xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
- xmlStructuredErrorFunc serror, void *ctx);
+ xmlStructuredErrorFunc serror,
+ void *ctx);
XMLPUBFUN int XMLCALL
xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
xmlSchemaValidityErrorFunc *err,
diff --git a/xmlschemas.c b/xmlschemas.c
index f72dc04..1ec8ac8 100644
--- a/xmlschemas.c
+++ b/xmlschemas.c
@@ -580,7 +580,7 @@
struct _xmlSchemaParserCtxt {
int type;
- void *userData; /* user specific data block */
+ void *errCtxt; /* user specific error context */
xmlSchemaValidityErrorFunc error; /* the callback in case of errors */
xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */
xmlSchemaValidError err;
@@ -957,7 +957,7 @@
*/
struct _xmlSchemaValidCtxt {
int type;
- void *userData; /* user specific data block */
+ void *errCtxt; /* user specific data block */
xmlSchemaValidityErrorFunc error; /* the callback in case of errors */
xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */
xmlStructuredErrorFunc serror;
@@ -1880,7 +1880,7 @@
ctxt->nberrors++;
ctxt->err = error;
channel = ctxt->error;
- data = ctxt->userData;
+ data = ctxt->errCtxt;
schannel = ctxt->serror;
}
__xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
@@ -1946,7 +1946,7 @@
ctxt->nberrors++;
ctxt->err = error;
channel = ctxt->error;
- data = ctxt->userData;
+ data = ctxt->errCtxt;
schannel = ctxt->serror;
}
__xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
@@ -2026,7 +2026,7 @@
channel = vctxt->warning;
}
schannel = vctxt->serror;
- data = vctxt->userData;
+ data = vctxt->errCtxt;
/*
* Error node. If we specify a line number, then
@@ -2078,7 +2078,7 @@
channel = pctxt->warning;
}
schannel = pctxt->serror;
- data = pctxt->userData;
+ data = pctxt->errCtxt;
__xmlRaiseError(schannel, channel, data, ctxt,
node, XML_FROM_SCHEMASP, error,
errorLevel, NULL, 0,
@@ -9951,7 +9951,9 @@
}
/* TODO: Pass user data. */
xmlSchemaSetParserErrors(vctxt->pctxt, vctxt->error,
- vctxt->warning, vctxt->userData);
+ vctxt->warning, vctxt->errCtxt);
+ xmlSchemaSetParserStructuredErrors(vctxt->pctxt, vctxt->serror,
+ vctxt->errCtxt);
}
return (0);
}
@@ -10149,7 +10151,9 @@
*/
newpctxt->schema = schema;
xmlSchemaSetParserErrors(newpctxt, pctxt->error, pctxt->warning,
- pctxt->userData);
+ pctxt->errCtxt);
+ xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror,
+ pctxt->errCtxt);
newpctxt->counter = pctxt->counter;
@@ -15623,7 +15627,9 @@
}
/* TODO: Pass user data. */
xmlSchemaSetValidErrors(ctxt->vctxt,
- ctxt->error, ctxt->warning, ctxt->userData);
+ ctxt->error, ctxt->warning, ctxt->errCtxt);
+ xmlSchemaSetValidStructuredErrors(ctxt->vctxt,
+ ctxt->serror, ctxt->errCtxt);
}
return (0);
}
@@ -21106,7 +21112,30 @@
return;
ctxt->error = err;
ctxt->warning = warn;
- ctxt->userData = ctx;
+ ctxt->errCtxt = ctx;
+ if (ctxt->vctxt != NULL)
+ xmlSchemaSetValidErrors(ctxt->vctxt, err, warn, ctx);
+}
+
+/**
+ * xmlSchemaSetParserStructuredErrors:
+ * @ctxt: a schema parser context
+ * @serror: the structured error function
+ * @ctx: the functions context
+ *
+ * Set the structured error callback
+ */
+void
+xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror,
+ void *ctx)
+{
+ if (ctxt == NULL)
+ return;
+ ctxt->serror = serror;
+ ctxt->errCtxt = ctx;
+ if (ctxt->vctxt != NULL)
+ xmlSchemaSetValidStructuredErrors(ctxt->vctxt, serror, ctx);
}
/**
@@ -21122,8 +21151,8 @@
*/
int
xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
- xmlSchemaValidityErrorFunc * err,
- xmlSchemaValidityWarningFunc * warn, void **ctx)
+ xmlSchemaValidityErrorFunc * err,
+ xmlSchemaValidityWarningFunc * warn, void **ctx)
{
if (ctxt == NULL)
return(-1);
@@ -21132,7 +21161,7 @@
if (warn != NULL)
*warn = ctxt->warning;
if (ctx != NULL)
- *ctx = ctxt->userData;
+ *ctx = ctxt->errCtxt;
return(0);
}
@@ -27185,7 +27214,7 @@
return;
ctxt->error = err;
ctxt->warning = warn;
- ctxt->userData = ctx;
+ ctxt->errCtxt = ctx;
if (ctxt->pctxt != NULL)
xmlSchemaSetParserErrors(ctxt->pctxt, err, warn, ctx);
}
@@ -27200,14 +27229,16 @@
*/
void
xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
- xmlStructuredErrorFunc serror, void *ctx)
+ xmlStructuredErrorFunc serror, void *ctx)
{
if (ctxt == NULL)
return;
ctxt->serror = serror;
ctxt->error = NULL;
ctxt->warning = NULL;
- ctxt->userData = ctx;
+ ctxt->errCtxt = ctx;
+ if (ctxt->pctxt != NULL)
+ xmlSchemaSetParserStructuredErrors(ctxt->pctxt, serror, ctx);
}
/**
@@ -27223,8 +27254,8 @@
*/
int
xmlSchemaGetValidErrors(xmlSchemaValidCtxtPtr ctxt,
- xmlSchemaValidityErrorFunc * err,
- xmlSchemaValidityWarningFunc * warn, void **ctx)
+ xmlSchemaValidityErrorFunc * err,
+ xmlSchemaValidityWarningFunc * warn, void **ctx)
{
if (ctxt == NULL)
return (-1);
@@ -27233,7 +27264,7 @@
if (warn != NULL)
*warn = ctxt->warning;
if (ctx != NULL)
- *ctx = ctxt->userData;
+ *ctx = ctxt->errCtxt;
return (0);
}