summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2001-07-12 01:32:04 +0000
committerDaniel Veillard <veillard@src.gnome.org>2001-07-12 01:32:04 +0000
commitbc9b7c87603deea9c1fffb2f5468973820654210 (patch)
tree4b99ddb6cefc509131dc550fc3ea5db959375e30
parent69513fd458715809880959a512e7ed9a6ff24b48 (diff)
downloadlibxslt-bc9b7c87603deea9c1fffb2f5468973820654210.tar.gz
libxslt-bc9b7c87603deea9c1fffb2f5468973820654210.tar.bz2
libxslt-bc9b7c87603deea9c1fffb2f5468973820654210.zip
provide context for error messages. Requires libxml head changes. fixed a
* libxslt/documents.c libxslt/extensions.c libxslt/extra.c libxslt/functions.c libxslt/imports.c libxslt/keys.c libxslt/namespaces.c libxslt/numbers.c libxslt/pattern.c libxslt/preproc.c libxslt/templates.c libxslt/transform.c libxslt/variables.c libxslt/xslt.c: provide context for error messages. Requires libxml head changes. * libxslt/xsltutils.c libxslt/xsltutils.h: fixed a --profile problem Daniel
-rw-r--r--ChangeLog11
-rw-r--r--TODO12
-rw-r--r--libxslt/documents.c3
-rw-r--r--libxslt/extensions.c4
-rw-r--r--libxslt/extra.c3
-rw-r--r--libxslt/functions.c43
-rw-r--r--libxslt/imports.c6
-rw-r--r--libxslt/keys.c4
-rw-r--r--libxslt/namespaces.c5
-rw-r--r--libxslt/numbers.c1
-rw-r--r--libxslt/pattern.c30
-rw-r--r--libxslt/preproc.c49
-rw-r--r--libxslt/templates.c1
-rw-r--r--libxslt/transform.c76
-rw-r--r--libxslt/variables.c20
-rw-r--r--libxslt/xslt.c30
-rw-r--r--libxslt/xsltutils.c83
-rw-r--r--libxslt/xsltutils.h4
18 files changed, 370 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 821dd60a..7617855e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Thu Jul 12 21:31:06 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * libxslt/documents.c libxslt/extensions.c libxslt/extra.c
+ libxslt/functions.c libxslt/imports.c libxslt/keys.c
+ libxslt/namespaces.c libxslt/numbers.c libxslt/pattern.c
+ libxslt/preproc.c libxslt/templates.c libxslt/transform.c
+ libxslt/variables.c libxslt/xslt.c: provide context for
+ error messages. Requires libxml head changes.
+ * libxslt/xsltutils.c libxslt/xsltutils.h: fixed a --profile
+ problem
+
Wed Jul 11 00:32:21 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libexslt/Makefile.am: initial EXSLT framework
diff --git a/TODO b/TODO
index ce860154..f43cc31b 100644
--- a/TODO
+++ b/TODO
@@ -9,7 +9,7 @@ Doc:
Design:
- seems that saving back XSLT stylesheet from a compiled form might
- be a bit ugly ...
+ be a bit ugly ... Yes forget about it, it's just twaeked to the extreme
ID and Key support:
-> done but namespace support in keys is not defined
@@ -119,3 +119,13 @@ Doc:
- put a page at http://xmlsoft.org/XSLT/
- generate/transform the DocBook to HTML
- add HTML to package
+
+Error handling:
+ -> check the version stuff, design a separate module for error interfacing
+ and default handling, parsing vs. runtime, fatal / compat / warning,
+ and lack of optionnal features.
+ -> reports context
+
+Profiler:
+ -> added looks good enough
+ -> autocorrection of initial calibration loop
diff --git a/libxslt/documents.c b/libxslt/documents.c
index 7f6684b2..1dfd2239 100644
--- a/libxslt/documents.c
+++ b/libxslt/documents.c
@@ -46,6 +46,7 @@ xsltNewDocument(xsltTransformContextPtr ctxt, xmlDocPtr doc) {
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
if (cur == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltNewDocument : malloc failed\n");
return(NULL);
@@ -73,6 +74,7 @@ xsltNewStyleDocument(xsltStylesheetPtr style, xmlDocPtr doc) {
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, style, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltNewStyleDocument : malloc failed\n");
return(NULL);
@@ -165,6 +167,7 @@ xsltLoadDocument(xsltTransformContextPtr ctxt, const xmlChar *URI) {
#ifdef LIBXML_XINCLUDE_ENABLED
xmlXIncludeProcess(doc);
#else
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltLoadDocument(%s) : XInclude processing not compiled in\n",
URI);
diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index 0dd97e49..d5c56b13 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -82,6 +82,7 @@ xsltNewExtDef(const xmlChar * prefix, const xmlChar * URI)
cur = (xsltExtDefPtr) xmlMalloc(sizeof(xsltExtDef));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewExtDef : malloc failed\n");
return (NULL);
@@ -145,6 +146,7 @@ xsltNewExtModule(xsltExtInitFunction initFunc,
cur = (xsltExtModulePtr) xmlMalloc(sizeof(xsltExtModule));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewExtModule : malloc failed\n");
return (NULL);
@@ -185,6 +187,7 @@ xsltNewExtData(xsltExtModulePtr extModule, void *extData)
return(NULL);
cur = (xsltExtDataPtr) xmlMalloc(sizeof(xsltExtData));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewExtData : malloc failed\n");
return (NULL);
@@ -414,6 +417,7 @@ xsltInitCtxtExts(xsltTransformContextPtr ctxt)
return (-1);
if (xmlHashAddEntry(ctxt->extInfos, def->URI,
(void *) data) < 0) {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"Failed to register module : %s\n",
def->URI);
diff --git a/libxslt/extra.c b/libxslt/extra.c
index 984c7df4..b95d82c2 100644
--- a/libxslt/extra.c
+++ b/libxslt/extra.c
@@ -117,12 +117,14 @@ xsltDebug(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
void
xsltFunctionNodeSet(xmlXPathParserContextPtr ctxt, int nargs){
if (nargs != 1) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"node-set() : expects one result-tree arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_XSLT_TREE)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"node-set() invalid arg expecting a result tree\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -145,6 +147,7 @@ xsltFunctionNodeSet(xmlXPathParserContextPtr ctxt, int nargs){
static void
xsltFunctionLocalTime(xmlXPathParserContextPtr ctxt, int nargs) {
if ((nargs < 0) || (nargs > 1)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"localTime() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
diff --git a/libxslt/functions.c b/libxslt/functions.c
index a4bc1c1e..fc5a55b9 100644
--- a/libxslt/functions.c
+++ b/libxslt/functions.c
@@ -73,12 +73,14 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){
if ((nargs < 1) || (nargs > 2)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"document() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if (ctxt->value == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"document() : invalid arg value\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -87,6 +89,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){
if (nargs == 2) {
if (ctxt->value->type != XPATH_NODESET) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"document() : invalid arg expecting a nodeset\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -133,6 +137,7 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){
*/
xmlXPathStringFunction(ctxt, 1);
if (ctxt->value->type != XPATH_STRING) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"document() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -175,6 +180,8 @@ xsltDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"document() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
@@ -213,6 +220,7 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
xsltTransformContextPtr tctxt;
if (nargs != 2) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"key() : expects two arguments\n");
ctxt->error = XPATH_INVALID_ARITY;
@@ -222,6 +230,7 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
obj2 = valuePop(ctxt);
if ((obj2 == NULL) ||
(ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"key() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -268,6 +277,8 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
if (prefix != NULL) {
keyURI = xmlXPathNsLookup(ctxt->context, prefix);
if (keyURI == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"key() : prefix %s is not bound\n", prefix);
}
@@ -283,6 +294,8 @@ xsltKeyFunction(xmlXPathParserContextPtr ctxt, int nargs){
valuePush(ctxt, obj2);
xmlXPathStringFunction(ctxt, 1);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"key() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -431,6 +444,8 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
ctxt->error = XPATH_INVALID_TYPE;
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"generate-id() : invalid arg expecting a node-set\n");
return;
@@ -450,6 +465,7 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
}
xmlXPathFreeObject(obj);
} else {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"generate-id() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
@@ -480,12 +496,14 @@ xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs){
const xmlChar *nsURI = NULL;
if (nargs != 1) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"system-property() : expects one string arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"system-property() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -501,6 +519,8 @@ xsltSystemPropertyFunction(xmlXPathParserContextPtr ctxt, int nargs){
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"system-property() : prefix %s is not bound\n", prefix);
}
@@ -573,12 +593,14 @@ xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
xsltTransformContextPtr tctxt;
if (nargs != 1) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"element-available() : expects one string arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"element-available() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -587,6 +609,7 @@ xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
obj = valuePop(ctxt);
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"element-available() : internal error tctxt == NULL\n");
xmlXPathFreeObject(obj);
@@ -601,6 +624,8 @@ xsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"element-available() : prefix %s is not bound\n", prefix);
}
@@ -634,12 +659,14 @@ xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
const xmlChar *nsURI = NULL;
if (nargs != 1) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : expects one string arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
@@ -653,6 +680,8 @@ xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
+ NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : prefix %s is not bound\n", prefix);
}
@@ -684,6 +713,7 @@ xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
xsltTransformContextPtr tctxt;
if (nargs != 0) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"current() : function uses no argument\n");
ctxt->error = XPATH_INVALID_ARITY;
@@ -691,6 +721,7 @@ xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
}
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"current() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
@@ -721,23 +752,27 @@ xsltExtFunctionTest(xmlXPathParserContextPtr ctxt, int nargs)
void *data;
if (testData == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtFunctionTest: not initialized\n");
return;
}
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtFunctionTest: failed to get the transformation context\n");
return;
}
data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
if (data == NULL) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtFunctionTest: failed to get module data\n");
return;
}
if (data != testData) {
+ xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtFunctionTest: got wrong module data\n");
return;
@@ -765,26 +800,31 @@ xsltExtElementTest(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr comment;
if (testData == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: not initialized\n");
return;
}
if (ctxt == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: no transformation context\n");
return;
}
if (node == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: no current node\n");
return;
}
if (inst == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: no instruction\n");
return;
}
if (ctxt->insert == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltExtElementTest: no insertion point\n");
return;
@@ -808,6 +848,7 @@ static void *
xsltExtInitTest(xsltTransformContextPtr ctxt, const xmlChar * URI)
{
if (testData != NULL) {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtInitTest: already initialized\n");
return (NULL);
@@ -839,11 +880,13 @@ xsltExtShutdownTest(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
const xmlChar * URI, void *data)
{
if (testData == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtShutdownTest: not initialized\n");
return;
}
if (data != testData) {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltExtShutdownTest: wrong data\n");
}
diff --git a/libxslt/imports.c b/libxslt/imports.c
index 51ec6b2b..be343574 100644
--- a/libxslt/imports.c
+++ b/libxslt/imports.c
@@ -73,6 +73,7 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
if (uriRef == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:import : missing href attribute\n");
goto error;
@@ -81,12 +82,14 @@ xsltParseStylesheetImport(xsltStylesheetPtr style, xmlNodePtr cur) {
base = xmlNodeGetBase(style->doc, cur);
URI = xmlBuildURI(uriRef, base);
if (URI == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:import : invalid URI reference %s\n", uriRef);
goto error;
}
import = xmlParseFile((const char *)URI);
if (import == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:import : unable to load %s\n", URI);
goto error;
@@ -130,6 +133,7 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
if (uriRef == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:include : missing href attribute\n");
goto error;
@@ -138,6 +142,7 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
base = xmlNodeGetBase(style->doc, cur);
URI = xmlBuildURI(uriRef, base);
if (URI == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:include : invalid URI reference %s\n", uriRef);
goto error;
@@ -145,6 +150,7 @@ xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) {
include = xsltLoadStyleDocument(style, URI);
if (include == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:include : unable to load %s\n", URI);
goto error;
diff --git a/libxslt/keys.c b/libxslt/keys.c
index 5d31b673..0f042f37 100644
--- a/libxslt/keys.c
+++ b/libxslt/keys.c
@@ -75,6 +75,7 @@ xsltNewKeyDef(const xmlChar *name, const xmlChar *nameURI) {
cur = (xsltKeyDefPtr) xmlMalloc(sizeof(xsltKeyDef));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewKeyDef : malloc failed\n");
return(NULL);
@@ -145,6 +146,7 @@ xsltNewKeyTable(const xmlChar *name, const xmlChar *nameURI) {
cur = (xsltKeyTablePtr) xmlMalloc(sizeof(xsltKeyTable));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewKeyTable : malloc failed\n");
return(NULL);
@@ -256,6 +258,7 @@ xsltAddKey(xsltStylesheetPtr style, const xmlChar *name,
}
key->comp = xmlXPathCompile(pattern);
if (key->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:key : XPath pattern compilation failed '%s'\n",
pattern);
@@ -263,6 +266,7 @@ xsltAddKey(xsltStylesheetPtr style, const xmlChar *name,
}
key->usecomp = xmlXPathCompile(use);
if (key->usecomp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:key : XPath pattern compilation failed '%s'\n",
use);
diff --git a/libxslt/namespaces.c b/libxslt/namespaces.c
index b76e864b..7149e631 100644
--- a/libxslt/namespaces.c
+++ b/libxslt/namespaces.c
@@ -69,6 +69,7 @@ xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) {
sprefix = xsltGetNsProp(node, (const xmlChar *)"stylesheet-prefix",
XSLT_NAMESPACE);
if (sprefix == NULL) {
+ xsltPrintErrorContext(NULL, style, node);
xsltGenericError(xsltGenericErrorContext,
"namespace-alias: stylesheet-prefix attribute missing\n");
return;
@@ -76,6 +77,7 @@ xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) {
rprefix = xsltGetNsProp(node, (const xmlChar *)"result-prefix",
XSLT_NAMESPACE);
if (rprefix == NULL) {
+ xsltPrintErrorContext(NULL, style, node);
xsltGenericError(xsltGenericErrorContext,
"namespace-alias: result-prefix attribute missing\n");
goto error;
@@ -86,6 +88,7 @@ xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) {
sNs = xmlSearchNs(node->doc, node, sprefix);
}
if ((sNs == NULL) || (sNs->href == NULL)) {
+ xsltPrintErrorContext(NULL, style, node);
xsltGenericError(xsltGenericErrorContext,
"namespace-alias: prefix %s not bound to any namespace\n",
sprefix);
@@ -97,6 +100,7 @@ xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) {
rNs = xmlSearchNs(node->doc, node, rprefix);
}
if ((rNs == NULL) || (rNs->href == NULL)) {
+ xsltPrintErrorContext(NULL, style, node);
xsltGenericError(xsltGenericErrorContext,
"namespace-alias: prefix %s not bound to any namespace\n",
rprefix);
@@ -105,6 +109,7 @@ xsltNamespaceAlias(xsltStylesheetPtr style, xmlNodePtr node) {
if (style->nsAliases == NULL)
style->nsAliases = xmlHashCreate(10);
if (style->nsAliases == NULL) {
+ xsltPrintErrorContext(NULL, style, node);
xsltGenericError(xsltGenericErrorContext,
"namespace-alias: cannot create hash table\n");
goto error;
diff --git a/libxslt/numbers.c b/libxslt/numbers.c
index 2c4d6242..9fea063a 100644
--- a/libxslt/numbers.c
+++ b/libxslt/numbers.c
@@ -1012,6 +1012,7 @@ xsltFormatNumberConversion(xsltDecimalFormatPtr self,
OUTPUT_NUMBER:
if (found_error != 0) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltFormatNumberConversion : error in format string, using default\n");
default_sign = (number < 0.0) ? 1 : 0;
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index 3523b207..51346f78 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -122,6 +122,7 @@ xsltNewCompMatch(void) {
cur = (xsltCompMatchPtr) xmlMalloc(sizeof(xsltCompMatch));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewCompMatch : malloc failed\n");
return(NULL);
@@ -199,6 +200,7 @@ xsltNewParserContext(void) {
cur = (xsltParserContextPtr) xmlMalloc(sizeof(xsltParserContext));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewParserContext : malloc failed\n");
return(NULL);
@@ -236,6 +238,7 @@ static int
xsltCompMatchAdd(xsltCompMatchPtr comp, xsltOp op, xmlChar *value,
xmlChar *value2) {
if (comp->nbStep >= 20) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompMatchAdd: overflow\n");
return(-1);
@@ -344,6 +347,7 @@ xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
xsltStepOpPtr step, select = NULL;
if ((comp == NULL) || (node == NULL) || (ctxt == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltTestCompMatch: null arg\n");
return(-1);
@@ -988,6 +992,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
xmlChar *lit2 = NULL;
if (CUR != '(') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ( expected\n");
ctxt->error = 1;
@@ -1001,6 +1006,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
return;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1016,6 +1022,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
return;
SKIP_BLANKS;
if (CUR != ',') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : , expected\n");
ctxt->error = 1;
@@ -1028,6 +1035,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
return;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1045,6 +1053,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
return;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1057,6 +1066,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1068,6 +1078,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1079,6 +1090,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
@@ -1087,11 +1099,13 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name, int aid) {
NEXT;
PUSH(XSLT_OP_NODE, NULL, NULL);
} else if (aid) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : expecting 'key' or 'id' or node type\n");
ctxt->error = 1;
return;
} else {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileIdKeyPattern : node type\n");
ctxt->error = 1;
@@ -1146,8 +1160,9 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
ns = xmlSearchNs(ctxt->doc, ctxt->elem, prefix);
if (ns == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
- "xsltCompileStepPattern : no namespace bound to prefix %s\n",
+ "xsltCompileStepPattern : no namespace bound to prefix %s\n",
prefix);
} else {
URL = xmlStrdup(ns->href);
@@ -1160,6 +1175,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
PUSH(XSLT_OP_ATTR, NULL, URL);
return;
}
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : Name expected\n");
ctxt->error = 1;
@@ -1176,6 +1192,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
PUSH(XSLT_OP_ALL, token, NULL);
goto parse_predicate;
} else {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : Name expected\n");
ctxt->error = 1;
@@ -1192,6 +1209,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
} else if (CUR == ':') {
NEXT;
if (NXT(1) != ':') {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : sequence '::' expected\n");
ctxt->error = 1;
@@ -1201,6 +1219,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
if (xmlStrEqual(token, (const xmlChar *) "child")) {
name = xsltScanName(ctxt);
if (name == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : QName expected\n");
ctxt->error = 1;
@@ -1219,6 +1238,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
} else if (xmlStrEqual(token, (const xmlChar *) "attribute")) {
name = xsltScanName(ctxt);
if (name == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : QName expected\n");
ctxt->error = 1;
@@ -1235,6 +1255,7 @@ xsltCompileStepPattern(xsltParserContextPtr ctxt, xmlChar *token) {
}
PUSH(XSLT_OP_ATTR, name, URL);
} else {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : 'child' or 'attribute' expected\n");
ctxt->error = 1;
@@ -1277,6 +1298,7 @@ parse_predicate:
NEXT;
}
if (!IS_CHAR(CUR)) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileStepPattern : ']' expected\n");
ctxt->error = 1;
@@ -1380,6 +1402,7 @@ xsltCompileLocationPathPattern(xsltParserContextPtr ctxt) {
xmlChar *name;
name = xsltScanName(ctxt);
if (name == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompileLocationPathPattern : Name expected\n");
ctxt->error = 1;
@@ -1429,6 +1452,7 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc, xmlNodePtr node) {
int current, start, end;
if (pattern == NULL) {
+ xsltPrintErrorContext(NULL, NULL, node); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompilePattern : NULL pattern\n");
return(NULL);
@@ -1448,6 +1472,7 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc, xmlNodePtr node) {
while ((pattern[end] != 0) && (pattern[end] != '|'))
end++;
if (current == end) {
+ xsltPrintErrorContext(NULL, NULL, node); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompilePattern : NULL pattern\n");
goto error;
@@ -1533,6 +1558,7 @@ xsltCompilePattern(const xmlChar *pattern, xmlDocPtr doc, xmlNodePtr node) {
current = end;
}
if (end == 0) {
+ xsltPrintErrorContext(NULL, NULL, node); /* TODO */
xsltGenericError(xsltGenericErrorContext,
"xsltCompilePattern : NULL pattern\n");
goto error;
@@ -1621,6 +1647,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
break;
case XSLT_OP_END:
case XSLT_OP_PREDICATE:
+ xsltPrintErrorContext(NULL, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltAddTemplate: invalid compiled pattern\n");
xsltFreeCompMatch(pat);
@@ -1702,6 +1729,7 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
list->next = pat;
}
} else {
+ xsltPrintErrorContext(NULL, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltAddTemplate: invalid compiled pattern\n");
xsltFreeCompMatch(pat);
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index 37c515cf..9772feb1 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -64,6 +64,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewStylePreComp : malloc failed\n");
style->errors++;
@@ -117,6 +118,7 @@ xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
cur->func = NULL;break;
default:
if (cur->func == NULL) {
+ xsltPrintErrorContext(NULL, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewStylePreComp : no function for type %d\n", type);
style->errors++;
@@ -254,6 +256,7 @@ xsltDocumentComp(xsltStylesheetPtr style, xmlNodePtr inst) {
base = xmlNodeGetBase(inst->doc, inst);
URL = xmlBuildURI(filename, base);
if (URL == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentComp: URL computation failed %s\n", filename);
style->warnings++;
@@ -307,6 +310,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
comp->number = 1;
else {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltSortComp: no support for data-type = %s\n", comp->stype);
comp->number = -1;
@@ -322,6 +326,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
else if (xmlStrEqual(comp->order, (const xmlChar *) "descending"))
comp->descending = 1;
else {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltSortComp: invalid value %s for order\n", comp->order);
comp->descending = -1;
@@ -342,6 +347,7 @@ xsltSortComp(xsltStylesheetPtr style, xmlNodePtr inst) {
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltSortComp: could not compile select expression '%s'\n",
comp->select);
@@ -407,6 +413,7 @@ xsltTextComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->noescape = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:text: disable-output-escaping allows only yes or no\n");
style->warnings++;
@@ -546,6 +553,7 @@ xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:copy-of : select is missing\n");
style->errors++;
@@ -553,6 +561,7 @@ xsltCopyOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:copy-of : could not compile select expression '%s'\n",
comp->select);
@@ -588,6 +597,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->noescape = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:value-of : disable-output-escaping allows only yes or no\n");
style->warnings++;
@@ -597,6 +607,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:value-of : select is missing\n");
style->errors++;
@@ -604,6 +615,7 @@ xsltValueOfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:value-of : could not compile select expression '%s'\n",
comp->select);
@@ -636,6 +648,7 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:with-param : name is missing\n");
style->errors++;
@@ -662,15 +675,18 @@ xsltWithParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
- if (inst->children != NULL)
+ if (inst->children != NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : content should be empty since select is present \n");
- style->warnings++;
+ style->warnings++;
+ }
}
}
@@ -720,6 +736,7 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
xmlStrEqual(prop, BAD_CAST("any"))) {
comp->numdata.level = prop;
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:number : invalid value %s for level\n", prop);
style->warnings++;
@@ -736,16 +753,19 @@ xsltNumberComp(xsltStylesheetPtr style, xmlNodePtr cur) {
prop = xsltGetNsProp(cur, (const xmlChar *)"letter-value", XSLT_NAMESPACE);
if (prop != NULL) {
if (xmlStrEqual(prop, BAD_CAST("alphabetic"))) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:number : letter-value 'alphabetic' not implemented\n");
style->warnings++;
TODO; /* xsl:number letter-value attribute alphabetic */
} else if (xmlStrEqual(prop, BAD_CAST("traditional"))) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:number : letter-value 'traditional' not implemented\n");
style->warnings++;
TODO; /* xsl:number letter-value attribute traditional */
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:number : invalid value %s for letter-value\n", prop);
style->warnings++;
@@ -822,6 +842,7 @@ xsltCallTemplateComp(xsltStylesheetPtr style, xmlNodePtr inst) {
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:call-template : name is missing\n");
style->errors++;
@@ -889,6 +910,7 @@ xsltApplyTemplatesComp(xsltStylesheetPtr style, xmlNodePtr inst) {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:apply-templates : could not compile select expression '%s'\n",
comp->select);
@@ -940,6 +962,7 @@ xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->test = xsltGetNsProp(inst, (const xmlChar *)"test", XSLT_NAMESPACE);
if (comp->test == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:if : test is not defined\n");
style->errors++;
@@ -947,6 +970,7 @@ xsltIfComp(xsltStylesheetPtr style, xmlNodePtr inst) {
}
comp->comp = xmlXPathCompile(comp->test);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:if : could not compile test expression '%s'\n",
comp->test);
@@ -975,6 +999,7 @@ xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->test = xsltGetNsProp(inst, (const xmlChar *)"test", XSLT_NAMESPACE);
if (comp->test == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:when : test is not defined\n");
style->errors++;
@@ -982,6 +1007,7 @@ xsltWhenComp(xsltStylesheetPtr style, xmlNodePtr inst) {
}
comp->comp = xmlXPathCompile(comp->test);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:when : could not compile test expression '%s'\n",
comp->test);
@@ -1011,12 +1037,14 @@ xsltForEachComp(xsltStylesheetPtr style, xmlNodePtr inst) {
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:for-each : select is missing\n");
style->errors++;
} else {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:for-each : could not compile select expression '%s'\n",
comp->select);
@@ -1051,6 +1079,7 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : name is missing\n");
style->errors++;
@@ -1077,15 +1106,18 @@ xsltVariableComp(xsltStylesheetPtr style, xmlNodePtr inst) {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
- if (inst->children != NULL)
+ if (inst->children != NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : content should be empty since select is present \n");
- style->warnings++;
+ style->warnings++;
+ }
}
}
@@ -1114,6 +1146,7 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : name is missing\n");
style->errors++;
@@ -1140,15 +1173,18 @@ xsltParamComp(xsltStylesheetPtr style, xmlNodePtr inst) {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
- if (inst->children != NULL)
+ if (inst->children != NULL) {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : content should be empty since select is present \n");
- style->warnings++;
+ style->warnings++;
+ }
}
}
@@ -1281,6 +1317,7 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
} else if (IS_XSLT_NAME(inst, "document")) {
xsltDocumentComp(style, inst);
} else {
+ xsltPrintErrorContext(NULL, style, inst);
xsltGenericError(xsltGenericDebugContext,
"xsltStylePreCompute: unknown xsl:%s\n", inst->name);
style->warnings++;
diff --git a/libxslt/templates.c b/libxslt/templates.c
index 899622d2..17c9c7db 100644
--- a/libxslt/templates.c
+++ b/libxslt/templates.c
@@ -135,6 +135,7 @@ xsltEvalXPathString(xsltTransformContextPtr ctxt, xmlXPathCompExprPtr comp) {
ret = res->stringval;
res->stringval = NULL;
} else {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xpath : string() function didn't return a String\n");
}
diff --git a/libxslt/transform.c b/libxslt/transform.c
index 47d37cab..3deecce6 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -170,6 +170,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
cur = (xsltTransformContextPtr) xmlMalloc(sizeof(xsltTransformContext));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, (xmlNodePtr)doc);
xsltGenericError(xsltGenericErrorContext,
"xsltNewTransformContext : malloc failed\n");
return(NULL);
@@ -182,7 +183,8 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
cur->templTab = (xsltTemplatePtr *)
xmlMalloc(10 * sizeof(xsltTemplatePtr));
if (cur->templTab == NULL) {
- xmlGenericError(xmlGenericErrorContext,
+ xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
+ xsltGenericError(xsltGenericErrorContext,
"xsltNewTransformContext: out of memory\n");
xmlFree(cur);
return(NULL);
@@ -219,6 +221,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
xmlXPathInit();
cur->xpathCtxt = xmlXPathNewContext(doc);
if (cur->xpathCtxt == NULL) {
+ xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltNewTransformContext : xmlXPathNewContext failed\n");
xmlFree(cur->templTab);
@@ -232,6 +235,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
cur->xpathCtxt->nsHash = style->nsHash;
docu = xsltNewDocument(cur, doc);
if (docu == NULL) {
+ xsltPrintErrorContext(cur, NULL, (xmlNodePtr)doc);
xsltGenericError(xsltGenericErrorContext,
"xsltNewTransformContext : xsltNewDocument failed\n");
xmlFree(cur->templTab);
@@ -326,11 +330,13 @@ xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
if (target != NULL)
xmlAddChild(target, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, target);
xsltGenericError(xsltGenericErrorContext,
"xsltCopyTextString: text copy failed\n");
}
return(copy);
}
+
/**
* xsltCopyText:
* @ctxt: a XSLT process context
@@ -349,7 +355,7 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
if ((cur->type != XML_TEXT_NODE) &&
(cur->type != XML_CDATA_SECTION_NODE))
return(NULL);
- if (cur->content == NULL)
+ if (cur->content == NULL)
return(NULL);
#ifdef WITH_XSLT_DEBUG_PROCESS
@@ -393,6 +399,7 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
if (target != NULL)
xmlAddChild(target, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, target);
xsltGenericError(xsltGenericErrorContext,
"xsltCopyText: text copy failed\n");
}
@@ -506,6 +513,7 @@ xsltCopyNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
}
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltCopyNode: copy %s failed\n", node->name);
}
@@ -609,6 +617,7 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (node->children != NULL)
xsltCopyTreeList(ctxt, node->children, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltCopyTree: copy %s failed\n", node->name);
}
@@ -673,6 +682,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: cdata copy failed\n");
}
@@ -691,6 +701,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: text copy failed\n");
}
@@ -700,6 +711,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
while ((cur != NULL) && (cur->type != XML_TEXT_NODE))
cur = cur->next;
if (cur == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: no text for attribute\n");
} else {
@@ -716,6 +728,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: text copy failed\n");
}
@@ -815,6 +828,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: cdata copy failed\n");
}
@@ -846,6 +860,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
+ xsltPrintErrorContext(ctxt, NULL, node);
xsltGenericError(xsltGenericErrorContext,
"xsltDefaultProcessOneNode: text copy failed\n");
}
@@ -995,6 +1010,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
CHECK_STOPPED;
if (ctxt->templNr >= xsltMaxDepth) {
+ xsltPrintErrorContext(ctxt, NULL, list);
xsltGenericError(xsltGenericErrorContext,
"xsltApplyOneTemplate: loop found ???\n");
xsltGenericError(xsltGenericErrorContext,
@@ -1138,6 +1154,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
if (!found) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltApplyOneTemplate: failed to find extension %s\n",
cur->name);
@@ -1267,6 +1284,14 @@ error:
child = profPop(ctxt);
total = end - start;
spent = total - child;
+ if (spent <= 0) {
+ /*
+ * Not possible unless the original calibration failed
+ * we can try to corret it on the fly.
+ */
+ xsltCalibrateAdjust(spent);
+ spent = 0;
+ }
templ->time += spent;
if (ctxt->profNr > 0)
@@ -1357,12 +1382,14 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
if (URL == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: href/URI-Reference not found\n");
return;
}
filename = xmlBuildURI(URL, (const xmlChar *) ctxt->outputFile);
if (filename == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: URL computation failed for %s\n",
URL);
@@ -1378,6 +1405,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
style = xsltNewStylesheet();
if (style == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: out of memory\n");
goto error;
@@ -1425,6 +1453,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
(xmlStrEqual(prop, (const xmlChar *) "text"))) {
style->method = prop;
} else {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"invalid value for method: %s\n", prop);
style->warnings++;
@@ -1459,6 +1488,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->standalone = 0;
} else {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"invalid value for standalone: %s\n",
prop);
@@ -1476,6 +1506,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->indent = 0;
} else {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"invalid value for indent: %s\n", prop);
style->warnings++;
@@ -1493,6 +1524,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->omitXmlDeclaration = 0;
} else {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"invalid value for omit-xml-declaration: %s\n",
prop);
@@ -1561,6 +1593,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (res == NULL)
goto error;
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: unsupported method xhtml, using html\n",
style->method);
@@ -1574,6 +1607,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (res == NULL)
goto error;
} else {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: unsupported method %s\n",
style->method);
@@ -1598,6 +1632,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
ret = xsltSaveResultToFilename((const char *) filename,
res, style, 0);
if (ret < 0) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltDocumentElem: unable to save to %s\n",
filename);
@@ -1643,14 +1678,16 @@ void xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node,
* called directly
*/
void
-xsltSort(xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED,
- xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst ATTRIBUTE_UNUSED,
+xsltSort(xsltTransformContextPtr ctxt,
+ xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst,
xsltStylePreCompPtr comp) {
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:sort : compilation failed\n");
return;
}
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:sort : improper use this should not be reached\n");
}
@@ -1786,6 +1823,7 @@ xsltText(xsltTransformContextPtr ctxt, xmlNodePtr node ATTRIBUTE_UNUSED,
while (text != NULL) {
if ((text->type != XML_TEXT_NODE) &&
(text->type != XML_CDATA_SECTION_NODE)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:text content problem\n");
break;
@@ -1840,6 +1878,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
prop = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:element : name is missing\n");
goto error;
@@ -1878,6 +1917,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
oldns = xmlSearchNs(inst->doc, inst, prefix);
if (oldns == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:element : no namespace bound to prefix %s\n", prefix);
} else {
@@ -1887,6 +1927,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
copy = xmlNewDocNode(ctxt->output, ns, name, NULL);
if (copy == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:element : creation of %s failed\n", name);
goto error;
@@ -1949,6 +1990,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (ctxt->insert == NULL)
return;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute : compilation failed\n");
return;
@@ -1960,6 +2002,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
return;
}
if (ctxt->insert->children != NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute : node already has children\n");
return;
@@ -1968,6 +2011,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
prop = xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *)"name",
XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute : name is missing\n");
goto error;
@@ -2001,6 +2045,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (prefix != NULL) {
ns = xmlSearchNs(inst->doc, inst, prefix);
if (ns == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute : no namespace bound to prefix %s\n", prefix);
} else {
@@ -2099,6 +2144,7 @@ xsltProcessingInstruction(xsltTransformContextPtr ctxt, xmlNodePtr node,
ncname = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)"name", XSLT_NAMESPACE);
if (ncname == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:processing-instruction : name is missing\n");
goto error;
@@ -2153,6 +2199,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:copy-of : compilation failed\n");
return;
@@ -2251,6 +2298,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:value-of : compilation failed\n");
return;
@@ -2287,6 +2335,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
}
if (copy == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsltValueOf: text copy failed\n");
}
@@ -2313,6 +2362,7 @@ xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr inst, xsltStylePreCompPtr comp)
{
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:number : compilation failed\n");
return;
@@ -2338,11 +2388,12 @@ xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
*/
void
xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr node,
- xmlNodePtr inst ATTRIBUTE_UNUSED,
+ xmlNodePtr inst,
xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
xsltTemplatePtr template;
if ((ctxt->templ == NULL) || (ctxt->templ->style == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:apply-imports : internal error no current template\n");
return;
@@ -2371,6 +2422,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (ctxt->insert == NULL)
return;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:call-template : compilation failed\n");
return;
@@ -2382,6 +2434,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (comp->templ == NULL) {
comp->templ = xsltFindTemplate(ctxt, comp->name, comp->ns);
if (comp->templ == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:call-template : template %s not found\n", comp->name);
return;
@@ -2454,6 +2507,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNsPtr *oldNamespaces;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:apply-templates : compilation failed\n");
return;
@@ -2491,6 +2545,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (comp->select != NULL) {
if (comp->comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:apply-templates : compilation failed\n");
goto error;
@@ -2629,6 +2684,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->xpathCtxt->doc=list->nodeTab[i]->doc->doc;
if ((ctxt->document =
xsltFindDocument(ctxt,list->nodeTab[i]->doc->doc))==NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:apply-templates : can't find doc\n");
goto error;
@@ -2692,12 +2748,14 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
*/
replacement = inst->children;
if (replacement == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:choose: empty content not allowed\n");
goto error;
}
if ((!IS_XSLT_ELEM(replacement)) ||
(!IS_XSLT_NAME(replacement, "when"))) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:choose: xsl:when expected first\n");
goto error;
@@ -2706,6 +2764,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltStylePreCompPtr wcomp = replacement->_private;
if ((wcomp == NULL) || (wcomp->test == NULL) || (wcomp->comp == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:choose: compilation failed !\n");
goto error;
@@ -2769,6 +2828,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
replacement = replacement->next;
}
if (replacement != NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:choose: unexpected content %s\n", replacement->name);
goto error;
@@ -2803,6 +2863,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:if : compilation failed\n");
return;
@@ -2879,6 +2940,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:for-each : compilation failed\n");
return;
@@ -2956,6 +3018,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->xpathCtxt->doc=list->nodeTab[i]->doc->doc;
if ((ctxt->document =
xsltFindDocument(ctxt,list->nodeTab[i]->doc->doc))==NULL) {
+ xsltPrintErrorContext(ctxt, NULL, inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:for-each : can't find doc\n");
goto error;
@@ -3111,6 +3174,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
if (res == NULL)
goto error;
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
+ xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltApplyStylesheetInternal: unsupported method xhtml, using html\n",
style->method);
@@ -3124,6 +3188,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
if (res == NULL)
goto error;
} else {
+ xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltApplyStylesheetInternal: unsupported method %s\n",
style->method);
@@ -3341,6 +3406,7 @@ xsltRunStylesheet(xsltStylesheetPtr style, xmlDocPtr doc,
tmp = xsltApplyStylesheetInternal(style, doc, params, output, NULL);
if (tmp == NULL) {
+ xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltRunStylesheet : run failed\n");
return (-1);
diff --git a/libxslt/variables.c b/libxslt/variables.c
index 74b76e15..6626fe4b 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -52,6 +52,7 @@ xsltNewStackElem(void) {
cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewStackElem : malloc failed\n");
return(NULL);
@@ -80,6 +81,7 @@ xsltCopyStackElem(xsltStackElemPtr elem) {
cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltCopyStackElem : malloc failed\n");
return(NULL);
@@ -332,6 +334,7 @@ xsltEvalVariable(xsltTransformContextPtr ctxt, xsltStackElemPtr elem,
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, precomp->inst);
xsltGenericError(xsltGenericErrorContext,
"Evaluating variable %s failed\n", elem->name);
#ifdef WITH_XSLT_DEBUG_VARIABLE
@@ -445,6 +448,7 @@ xsltEvalGlobalVariable(xsltStackElemPtr elem, xsltTransformContextPtr ctxt) {
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, precomp->inst);
xsltGenericError(xsltGenericErrorContext,
"Evaluating global variable %s failed\n", elem->name);
#ifdef WITH_XSLT_DEBUG_VARIABLE
@@ -555,6 +559,7 @@ xsltEvalGlobalVariables(xsltTransformContextPtr ctxt) {
elem->name, elem->nameURI, def);
} else if ((elem->comp != NULL) &&
(elem->comp->type == XSLT_FUNC_VARIABLE)) {
+ xsltPrintErrorContext(ctxt, style, elem->comp->inst);
xsltGenericError(xsltGenericErrorContext,
"Global variable %s already defined\n", elem->name);
}
@@ -692,6 +697,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
prefix);
if (ns == NULL) {
+ xsltPrintErrorContext(ctxt, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"user param : no namespace bound to prefix %s\n", prefix);
href = NULL;
@@ -734,6 +740,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
xmlXPathFreeCompExpr(comp);
}
if (result == NULL) {
+ xsltPrintErrorContext(ctxt, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"Evaluating user parameter %s failed\n", name);
} else {
@@ -770,6 +777,7 @@ xsltEvalUserParams(xsltTransformContextPtr ctxt, const char **params) {
ncname, href, elem);
if (res != 0) {
xsltFreeStackElem(elem);
+ xsltPrintErrorContext(ctxt, style, NULL);
xsltGenericError(xsltGenericErrorContext,
"Global parameter %s already defined\n", ncname);
}
@@ -842,6 +850,7 @@ xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr comp,
if (xsltCheckStackElem(ctxt, comp->name, comp->ns) != 0) {
if (!param) {
+ xsltPrintErrorContext(ctxt, NULL, comp->inst);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : redefining %s\n", comp->name);
}
@@ -956,12 +965,14 @@ xsltParseStylesheetCallerParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) {
return(NULL);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : compilation error\n");
return(NULL);
}
if (comp->name == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : missing name attribute\n");
return(NULL);
@@ -1006,12 +1017,14 @@ xsltParseGlobalVariable(xsltStylesheetPtr style, xmlNodePtr cur) {
xsltStylePreCompute(style, cur);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : compilation failed\n");
return;
}
if (comp->name == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : missing name attribute\n");
return;
@@ -1045,12 +1058,14 @@ xsltParseGlobalParam(xsltStylesheetPtr style, xmlNodePtr cur) {
xsltStylePreCompute(style, cur);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : compilation failed\n");
return;
}
if (comp->name == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : missing name attribute\n");
return;
@@ -1083,12 +1098,14 @@ xsltParseStylesheetVariable(xsltTransformContextPtr ctxt, xmlNodePtr cur) {
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : compilation failed\n");
return;
}
if (comp->name == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:variable : missing name attribute\n");
return;
@@ -1120,12 +1137,14 @@ xsltParseStylesheetParam(xsltTransformContextPtr ctxt, xmlNodePtr cur) {
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : compilation failed\n");
return;
}
if (comp->name == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:param : missing name attribute\n");
return;
@@ -1179,6 +1198,7 @@ xsltXPathVariableLookup(void *ctxt, const xmlChar *name,
context = (xsltTransformContextPtr) ctxt;
ret = xsltVariableLookup(context, name, ns_uri);
if (ret == NULL) {
+ xsltPrintErrorContext(ctxt, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"unregistered variable %s\n", name);
}
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index 4ff5f0a7..55629d09 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -253,6 +253,7 @@ xsltNewTemplate(void) {
cur = (xsltTemplatePtr) xmlMalloc(sizeof(xsltTemplate));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewTemplate : malloc failed\n");
return(NULL);
@@ -312,6 +313,7 @@ xsltNewStylesheet(void) {
cur = (xsltStylesheetPtr) xmlMalloc(sizeof(xsltStylesheet));
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltNewStylesheet : malloc failed\n");
return(NULL);
@@ -549,6 +551,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
(xmlStrEqual(prop, (const xmlChar *) "text"))) {
style->method = prop;
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"invalid value for method: %s\n", prop);
style->warnings++;
@@ -585,6 +588,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->standalone = 0;
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"invalid value for standalone: %s\n", prop);
style->warnings++;
@@ -599,6 +603,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->indent = 0;
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"invalid value for indent: %s\n", prop);
style->warnings++;
@@ -614,6 +619,7 @@ xsltParseStylesheetOutput(xsltStylesheetPtr style, xmlNodePtr cur)
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->omitXmlDeclaration = 0;
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"invalid value for omit-xml-declaration: %s\n",
prop);
@@ -688,6 +694,7 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
if (prop != NULL) {
format = xsltDecimalFormatGetByName(style, prop);
if (format != NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylestyleDecimalFormat: %s already exists\n", prop);
style->warnings++;
@@ -695,6 +702,7 @@ xsltParseStylesheetDecimalFormat(xsltStylesheetPtr style, xmlNodePtr cur)
}
format = xsltNewDecimalFormat(prop);
if (format == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylestyleDecimalFormat: failed creating new decimal-format\n");
style->errors++;
@@ -790,6 +798,7 @@ xsltParseStylesheetPreserveSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
elements = xsltGetNsProp(cur, (const xmlChar *)"elements", XSLT_NAMESPACE);
if (elements == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetPreserveSpace: missing elements attribute\n");
style->warnings++;
@@ -866,6 +875,7 @@ xsltParseStylesheetExtPrefix(xsltStylesheetPtr style, xmlNodePtr cur) {
else
ns = xmlSearchNs(style->doc, cur, prefix);
if (ns == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:extension-element-prefix : undefined namespace %s\n",
prefix);
@@ -903,6 +913,7 @@ xsltParseStylesheetStripSpace(xsltStylesheetPtr style, xmlNodePtr cur) {
elements = xsltGetNsProp(cur, (const xmlChar *)"elements", XSLT_NAMESPACE);
if (elements == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetStripSpace: missing elements attribute\n");
style->warnings++;
@@ -982,6 +993,7 @@ xsltParseStylesheetExcludePrefix(xsltStylesheetPtr style, xmlNodePtr cur) {
else
ns = xmlSearchNs(style->doc, cur, prefix);
if (ns == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:exclude-result-prefixes : undefined namespace %s\n",
prefix);
@@ -1175,6 +1187,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
if (style->nsHash == NULL) {
style->nsHash = xmlHashCreate(10);
if (style->nsHash == NULL) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltGatherNamespaces: failed to create hash table\n");
style->errors++;
@@ -1183,6 +1196,7 @@ xsltGatherNamespaces(xsltStylesheetPtr style) {
}
URI = xmlHashLookup(style->nsHash, ns->prefix);
if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"Namespaces prefix %s used for multiple namespaces\n");
style->warnings++;
@@ -1282,6 +1296,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
noesc = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:text: disable-output-escaping allows only yes or no\n");
style->warnings++;
@@ -1293,6 +1308,7 @@ xsltParseTemplateContent(xsltStylesheetPtr style, xsltTemplatePtr ret,
while (text != NULL) {
if ((text->type != XML_TEXT_NODE) &&
(text->type != XML_CDATA_SECTION_NODE)) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseTemplateContent: xslt:text content problem\n");
style->errors++;
@@ -1385,6 +1401,7 @@ skip_children:
xmlNodePtr param = cur;
cur = cur->next;
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseTemplateContent: ignoring misplaced param element\n");
style->warnings++;
@@ -1439,6 +1456,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
"xsltParseStylesheetKey: name %s\n", name);
#endif
} else {
+ xsltPrintErrorContext(NULL, style, key);
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing name\n");
style->errors++;
@@ -1447,6 +1465,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
match = xsltGetNsProp(key, (const xmlChar *)"match", XSLT_NAMESPACE);
if (match == NULL) {
+ xsltPrintErrorContext(NULL, style, key);
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing match\n");
style->errors++;
@@ -1455,6 +1474,7 @@ xsltParseStylesheetKey(xsltStylesheetPtr style, xmlNodePtr key) {
use = xsltGetNsProp(key, (const xmlChar *)"use", XSLT_NAMESPACE);
if (use == NULL) {
+ xsltPrintErrorContext(NULL, style, key);
xsltGenericError(xsltGenericErrorContext,
"xsl:key : error missing use\n");
style->errors++;
@@ -1612,12 +1632,14 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
prop = xsltGetNsProp(top, (const xmlChar *)"version", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, style, top);
xsltGenericError(xsltGenericErrorContext,
"xsl:version is missing: document may not be a stylesheet\n");
style->warnings++;
} else {
if ((!xmlStrEqual(prop, (const xmlChar *)"1.0")) &&
(!xmlStrEqual(prop, (const xmlChar *)"1.1"))) {
+ xsltPrintErrorContext(NULL, style, top);
xsltGenericError(xsltGenericErrorContext,
"xsl:version: only 1.0 features are supported\n");
/* TODO set up compatibility when not XSLT 1.0 */
@@ -1661,6 +1683,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
continue;
}
if (IS_XSLT_NAME(cur, "import")) {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetTop: ignoring misplaced import element\n");
style->errors++;
@@ -1690,6 +1713,7 @@ xsltParseStylesheetTop(xsltStylesheetPtr style, xmlNodePtr top) {
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
xsltNamespaceAlias(style, cur);
} else {
+ xsltPrintErrorContext(NULL, style, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetTop: ignoring unknown %s element\n",
cur->name);
@@ -1729,6 +1753,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
*/
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
+ xsltPrintErrorContext(NULL, ret, (xmlNodePtr) doc);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : empty stylesheet\n");
ret->doc = NULL;
@@ -1756,6 +1781,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
*/
prop = xsltGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
if (prop == NULL) {
+ xsltPrintErrorContext(NULL, ret, cur);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetProcess : document is not a stylesheet\n");
ret->doc = NULL;
@@ -1769,6 +1795,7 @@ xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) {
#endif
if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) {
+ xsltPrintErrorContext(NULL, ret, cur);
xsltGenericError(xsltGenericErrorContext,
"xsl:version: only 1.0 features are supported\n");
/* TODO set up compatibility when not XSLT 1.0 */
@@ -1851,6 +1878,7 @@ xsltParseStylesheetFile(const xmlChar* filename) {
doc = xmlParseFile((const char *) filename);
if (doc == NULL) {
+ xsltPrintErrorContext(NULL, NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"xsltParseStylesheetFile : cannot parse %s\n", filename);
return(NULL);
@@ -2011,6 +2039,7 @@ xsltLoadStylesheetPI(xmlDocPtr doc) {
#endif
URI = xmlParseURI((const char *) href);
if (URI == NULL) {
+ xsltPrintErrorContext(NULL, NULL, child);
xsltGenericError(xsltGenericErrorContext,
"xml-stylesheet : href %s is not valid\n", href);
xmlFree(href);
@@ -2031,6 +2060,7 @@ xsltLoadStylesheetPI(xmlDocPtr doc) {
else
ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
if (ID == NULL) {
+ xsltPrintErrorContext(NULL, NULL, child);
xsltGenericError(xsltGenericErrorContext,
"xml-stylesheet : no ID %s found\n", URI->fragment);
} else {
diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c
index 0c06c0d8..a9285a9e 100644
--- a/libxslt/xsltutils.c
+++ b/libxslt/xsltutils.c
@@ -272,6 +272,73 @@ xsltSetGenericDebugFunc(void *ctx, xmlGenericErrorFunc handler) {
xsltGenericDebug = xsltGenericDebugDefaultFunc;
}
+/**
+ * xsltPrintErrorContext:
+ * @ctxt: the transformation context
+ * @style: the stylesheet
+ * @node: the current node being processed
+ *
+ * Display the context of an error.
+ */
+void
+xsltPrintErrorContext(xsltTransformContextPtr ctxt,
+ xsltStylesheetPtr style, xmlNodePtr node) {
+ int line = 0;
+ const xmlChar *file = NULL;
+ const xmlChar *name = NULL;
+ const char *type = "error";
+
+ if ((node != NULL) && (ctxt != NULL))
+ node = ctxt->inst;
+
+ if (node != NULL) {
+ if ((node->type == XML_DOCUMENT_NODE) ||
+ (node->type == XML_HTML_DOCUMENT_NODE)) {
+ xmlDocPtr doc = (xmlDocPtr) node;
+
+ file = doc->URL;
+ } else {
+ if (node->type == XML_ELEMENT_NODE) {
+ line = (int) node->content;
+ }
+ if ((node->doc != NULL) && (node->doc->URL != NULL))
+ file = node->doc->URL;
+ if (node->name != NULL)
+ name = node->name;
+ }
+ }
+
+ if (ctxt != NULL)
+ type = "runtime error";
+ else if (style != NULL)
+ type = "compilation error";
+
+ if ((file != NULL) && (line != 0) && (name != NULL))
+ xsltGenericError(xsltGenericErrorContext,
+ "%s: file %s line %d element %s\n",
+ type, file, line, name);
+ else if ((file != NULL) && (name != NULL))
+ xsltGenericError(xsltGenericErrorContext,
+ "%s: file %s element %s\n",
+ type, file, name);
+ else if ((file != NULL) && (line != 0))
+ xsltGenericError(xsltGenericErrorContext,
+ "%s: file %s line %d\n",
+ type, file, line);
+ else if (file != NULL)
+ xsltGenericError(xsltGenericErrorContext,
+ "%s: file %s\n",
+ type, file);
+ else if (name != NULL)
+ xsltGenericError(xsltGenericErrorContext,
+ "%s: element %s\n",
+ type, name);
+ else
+ xsltGenericError(xsltGenericErrorContext,
+ "%s\n",
+ type);
+}
+
/************************************************************************
* *
* QNames *
@@ -964,6 +1031,8 @@ xsltSaveResultToFd(int fd, xmlDocPtr result, xsltStylesheetPtr style) {
* *
************************************************************************/
+static long calibration = -1;
+
/**
* xsltCalibrateTimestamps:
*
@@ -982,6 +1051,17 @@ xsltCalibrateTimestamps(void) {
}
/**
+ * xsltCalibrateAdjust:
+ * @delta: a negative dealy value found
+ *
+ * Used for to correct the calibration for xsltTimestamp()
+ */
+void
+xsltCalibrateAdjust(long delta) {
+ calibration += delta;
+}
+
+/**
* xsltTimestamp:
*
* Used for gathering profiling data
@@ -992,12 +1072,11 @@ xsltCalibrateTimestamps(void) {
long
xsltTimestamp(void) {
#ifdef HAVE_GETTIMEOFDAY
- static long calibration = -1;
static struct timeval startup;
struct timeval cur;
long msec;
- if (calibration == -1) {
+ if (calibration < 0) {
gettimeofday(&startup, NULL);
calibration = 0;
calibration = xsltCalibrateTimestamps();
diff --git a/libxslt/xsltutils.h b/libxslt/xsltutils.h
index fab5e4b0..c441e7d7 100644
--- a/libxslt/xsltutils.h
+++ b/libxslt/xsltutils.h
@@ -69,6 +69,9 @@ extern void *xsltGenericErrorContext;
extern xmlGenericErrorFunc xsltGenericDebug;
extern void *xsltGenericDebugContext;
+void xsltPrintErrorContext (xsltTransformContextPtr ctxt,
+ xsltStylesheetPtr style,
+ xmlNodePtr node);
void xsltMessage (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNodePtr inst);
@@ -117,6 +120,7 @@ void xsltSaveProfiling (xsltTransformContextPtr ctxt,
FILE *output);
long xsltTimestamp (void);
+void xsltCalibrateAdjust (long delta);
#ifdef __cplusplus
}