+Tue Oct 15 18:02:37 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+ * libxslt/xsltInternals.h libxslt/xsltutils.[ch]: added the
+ possibility to register a transformation context specific
+ error handler, with xsltSetTransformErrorFunc() and provided
+ a new routine xsltTransformError() to handle contextual errors,
+ this should fix #94435
+ * libxslt/*.c: modified all the code to use the context specific
+ error handling, as a result xsltPrintErrorContext() is not called
+ anymore except internally from xsltTransformError()
+
Tue Oct 15 14:52:23 CEST 2002 Daniel Veillard <daniel@veillard.com>
* libxslt/transform.c: closing #94933, any error will make
if (ctxt->insert == NULL)
return;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:attribute : compilation failed\n");
return;
}
return;
}
if (ctxt->insert->children != NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:attribute : node already has children\n");
return;
}
xsltEvalAttrValueTemplate(ctxt, inst, (const xmlChar *) "name",
XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:attribute : name is missing\n");
goto error;
}
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",
+ xsltTransformError(ctxt, NULL, inst,
+ "xsl:attribute : no namespace bound to prefix %s\n",
prefix);
} else {
ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert);
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
if (cur == NULL) {
- xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
"xsltNewDocument : malloc failed\n");
return(NULL);
}
cur = (xsltDocumentPtr) xmlMalloc(sizeof(xsltDocument));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, style, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, (xmlNodePtr) doc,
"xsltNewStyleDocument : malloc failed\n");
return(NULL);
}
res = xsltCheckRead(ctxt->sec, ctxt, URI);
if (res == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltLoadDocument: read rights for %s denied\n",
URI);
return(NULL);
#ifdef LIBXML_XINCLUDE_ENABLED
xmlXIncludeProcess(doc);
#else
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltLoadDocument(%s) : XInclude processing not compiled in\n",
URI);
#endif
res = xsltCheckRead(sec, NULL, URI);
if (res == 0) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltLoadStyleDocument: read rights for %s denied\n",
URI);
return(NULL);
cur = (xsltExtDefPtr) xmlMalloc(sizeof(xsltExtDef));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewExtDef : malloc failed\n");
return (NULL);
}
cur = (xsltExtModulePtr) xmlMalloc(sizeof(xsltExtModule));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewExtModule : malloc failed\n");
return (NULL);
}
return(NULL);
cur = (xsltExtDataPtr) xmlMalloc(sizeof(xsltExtData));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewExtData : malloc failed\n");
return (NULL);
}
cur = (xsltExtElementPtr) xmlMalloc(sizeof(xsltExtElement));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewExtElement : malloc failed\n");
return (NULL);
}
return (NULL);
if (xmlHashAddEntry(ctxt->extInfos, URI,
(void *) data) < 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"Failed to register module data: %s\n", URI);
if (module->shutdownFunc)
module->shutdownFunc(ctxt, URI, extData);
cur = (xsltElemPreCompPtr) xmlMalloc (sizeof(xsltElemPreComp));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, NULL,
"xsltNewExtElement : malloc failed\n");
return (NULL);
}
" calling xsltGetExtData\n");
data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
if (data == NULL) {
- xsltPrintErrorContext(tctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(tctxt, NULL, NULL,
"xsltExtElementTest: not initialized\n");
return;
}
}
if (tctxt == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"xsltExtFunctionTest: failed to get the transformation context\n");
return;
}
if (data == NULL)
data = xsltGetExtData(tctxt, (const xmlChar *) XSLT_DEFAULT_URL);
if (data == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"xsltExtFunctionTest: failed to get module data\n");
return;
}
if (data != testData) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"xsltExtFunctionTest: got wrong module data\n");
return;
}
xsltElemPreCompPtr ret;
if (style == NULL) {
- xsltPrintErrorContext(NULL, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, inst,
"xsltExtElementTest: no transformation context\n");
return (NULL);
}
" calling xsltStyleGetExtData\n");
xsltStyleGetExtData(style, (const xmlChar *) XSLT_DEFAULT_URL);
if (testStyleData == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltExtElementPreCompTest: not initialized\n");
style->errors++;
return (NULL);
}
}
if (inst == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltExtElementPreCompTest: no instruction\n");
style->errors++;
return (NULL);
" calling xsltGetExtData\n");
xsltGetExtData(ctxt, (const xmlChar *) XSLT_DEFAULT_URL);
if (testData == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltExtElementTest: not initialized\n");
return;
}
}
if (ctxt == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltExtElementTest: no transformation context\n");
return;
}
if (node == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltExtElementTest: no current node\n");
return;
}
if (inst == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltExtElementTest: no instruction\n");
return;
}
if (ctxt->insert == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltExtElementTest: no insertion point\n");
return;
}
" calling xsltStyleGetExtData\n");
xsltStyleGetExtData(ctxt->style, URI);
if (testStyleData == NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltExtInitTest: not initialized\n");
return (NULL);
}
}
if (testData != NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltExtInitTest: already initialized\n");
return (NULL);
}
xsltExtShutdownTest(xsltTransformContextPtr ctxt,
const xmlChar * URI, void *data) {
if (testData == NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltExtShutdownTest: not initialized\n");
return;
}
if (data != testData) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltExtShutdownTest: wrong data\n");
}
testData = NULL;
const xmlChar * URI)
{
if (testStyleData != NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltExtInitTest: already initialized\n");
return (NULL);
}
return;
}
if (data != testStyleData) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltExtShutdownTest: wrong data\n");
}
testStyleData = NULL;
}
static void
-xsltDebugDumpExtensionsCallback(void* function, FILE *output, const xmlChar* name, const xmlChar* URI, const xmlChar* not_used) {
+xsltDebugDumpExtensionsCallback(void* function ATTRIBUTE_UNUSED,
+ FILE *output, const xmlChar* name,
+ const xmlChar* URI,
+ const xmlChar* not_used ATTRIBUTE_UNUSED) {
if (!name||!URI)
return;
fprintf(output,"{%s}%s\n",URI,name);
void
xsltFunctionNodeSet(xmlXPathParserContextPtr ctxt, int nargs){
if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"node-set() : expects one result-tree arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_XSLT_TREE) &&
(ctxt->value->type != XPATH_NODESET))) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"node-set() invalid arg expecting a result tree\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
struct tm *local_tm;
if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"localTime() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
if ((nargs < 1) || (nargs > 2)) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL,
- NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"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,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"document() : invalid arg value\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
if (nargs == 2) {
if (ctxt->value->type != XPATH_NODESET) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"document() : invalid arg expecting a nodeset\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
*/
xmlXPathStringFunction(ctxt, 1);
if (ctxt->value->type != XPATH_STRING) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL,
- NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"document() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
if (obj2 != NULL)
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"document() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
} else {
xsltTransformContextPtr tctxt;
if (nargs != 2) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"key() : expects two arguments\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
obj2 = valuePop(ctxt);
if ((obj2 == NULL) ||
(ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"key() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
xmlXPathFreeObject(obj2);
if (prefix != NULL) {
keyURI = xmlXPathNsLookup(ctxt->context, prefix);
if (keyURI == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"key() : prefix %s is not bound\n", prefix);
}
xmlFree(prefix);
valuePush(ctxt, obj2);
xmlXPathStringFunction(ctxt, 1);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"key() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
xmlXPathFreeObject(obj1);
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
ctxt->error = XPATH_INVALID_TYPE;
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"generate-id() : invalid arg expecting a node-set\n");
return;
}
}
xmlXPathFreeObject(obj);
} else {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"generate-id() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
const xmlChar *nsURI = NULL;
if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"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,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"system-property() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"system-property() : prefix %s is not bound\n", prefix);
}
}
xsltTransformContextPtr tctxt;
if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"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,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"element-available() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
obj = valuePop(ctxt);
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"element-available() : internal error tctxt == NULL\n");
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewBoolean(0));
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"element-available() : prefix %s is not bound\n", prefix);
}
}
const xmlChar *nsURI = NULL;
if (nargs != 1) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"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,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"function-available() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
- NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"function-available() : prefix %s is not bound\n", prefix);
}
}
xsltTransformContextPtr tctxt;
if (nargs != 0) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"current() : function uses no argument\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
- xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
"current() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
} else {
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
if (uriRef == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:import : missing href attribute\n");
goto error;
}
base = xmlNodeGetBase(style->doc, cur);
URI = xmlBuildURI(uriRef, base);
if (URI == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:import : invalid URI reference %s\n", uriRef);
goto error;
}
*/
sec = xsltGetDefaultSecurityPrefs();
if (sec != NULL) {
- int res;
+ int secres;
- res = xsltCheckRead(sec, NULL, URI);
- if (res == 0) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ secres = xsltCheckRead(sec, NULL, URI);
+ if (secres == 0) {
+ xsltTransformError(NULL, NULL, NULL,
"xsl:import: read rights for %s denied\n",
URI);
goto error;
import = xmlParseFile((const char *)URI);
if (import == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:import : unable to load %s\n", URI);
goto error;
}
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
if (uriRef == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:include : missing href attribute\n");
goto error;
}
base = xmlNodeGetBase(style->doc, cur);
URI = xmlBuildURI(uriRef, base);
if (URI == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:include : invalid URI reference %s\n", uriRef);
goto error;
}
include = xsltLoadStyleDocument(style, URI);
if (include == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:include : unable to load %s\n", URI);
goto error;
}
cur = (xsltKeyDefPtr) xmlMalloc(sizeof(xsltKeyDef));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewKeyDef : malloc failed\n");
return(NULL);
}
cur = (xsltKeyTablePtr) xmlMalloc(sizeof(xsltKeyTable));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewKeyTable : malloc failed\n");
return(NULL);
}
end++;
}
if (current == end) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"key pattern is empty\n");
style->errors++;
goto error;
#endif
key->comp = xmlXPathCompile(pattern);
if (key->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:key : XPath pattern compilation failed '%s'\n",
pattern);
style->errors++;
}
key->usecomp = xmlXPathCompile(use);
if (key->usecomp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:key : XPath pattern compilation failed '%s'\n",
use);
style->errors++;
res->stringval = NULL;
}
} else {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xpath : string() function didn't return a String\n");
}
}
sprefix = xsltGetNsProp(node, (const xmlChar *)"stylesheet-prefix",
XSLT_NAMESPACE);
if (sprefix == NULL) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"namespace-alias: stylesheet-prefix attribute missing\n");
return;
}
rprefix = xsltGetNsProp(node, (const xmlChar *)"result-prefix",
XSLT_NAMESPACE);
if (rprefix == NULL) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"namespace-alias: result-prefix attribute missing\n");
goto error;
}
sNs = xmlSearchNs(node->doc, node, sprefix);
}
if ((sNs == NULL) || (sNs->href == NULL)) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"namespace-alias: prefix %s not bound to any namespace\n",
sprefix);
goto error;
rNs = xmlSearchNs(node->doc, node, rprefix);
}
if ((rNs == NULL) || (rNs->href == NULL)) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"namespace-alias: prefix %s not bound to any namespace\n",
rprefix);
goto error;
if (style->nsAliases == NULL)
style->nsAliases = xmlHashCreate(10);
if (style->nsAliases == NULL) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"namespace-alias: cannot create hash table\n");
goto error;
}
OUTPUT_NUMBER:
if (found_error != 0) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltFormatNumberConversion : error in format string, using default\n");
default_sign = (number < 0.0) ? 1 : 0;
prefix_length = suffix_length = 0;
cur = (xsltCompMatchPtr) xmlMalloc(sizeof(xsltCompMatch));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewCompMatch : malloc failed\n");
return(NULL);
}
cur = (xsltParserContextPtr) xmlMalloc(sizeof(xsltParserContext));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewParserContext : malloc failed\n");
return(NULL);
}
xsltOp op, xmlChar * value, xmlChar * value2)
{
if (comp->nbStep >= 40) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompMatchAdd: overflow\n");
return (-1);
}
xsltStepOpPtr step, select = NULL;
if ((comp == NULL) || (node == NULL) || (ctxt == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltTestCompMatch: null arg\n");
return(-1);
}
xmlChar *lit2 = NULL;
if (CUR != '(') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ( expected\n");
ctxt->error = 1;
return;
return;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
return;
SKIP_BLANKS;
if (CUR != ',') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : , expected\n");
ctxt->error = 1;
return;
return;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
return;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
NEXT;
SKIP_BLANKS;
if (CUR != ')') {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : ) expected\n");
ctxt->error = 1;
return;
NEXT;
PUSH(XSLT_OP_NODE, NULL, NULL);
} else if (aid) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : expecting 'key' or 'id' or node type\n");
ctxt->error = 1;
return;
} else {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileIdKeyPattern : node type\n");
ctxt->error = 1;
return;
ns = xmlSearchNs(ctxt->doc, ctxt->elem, prefix);
if (ns == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : no namespace bound to prefix %s\n",
prefix);
} else {
PUSH(XSLT_OP_ATTR, NULL, URL);
return;
}
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : Name expected\n");
ctxt->error = 1;
goto error;
PUSH(XSLT_OP_ALL, token, NULL);
goto parse_predicate;
} else {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : Name expected\n");
ctxt->error = 1;
goto error;
token = xsltScanName(ctxt);
ns = xmlSearchNs(ctxt->doc, ctxt->elem, prefix);
if (ns == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : no namespace bound to prefix %s\n",
prefix);
ctxt->error = 1;
NEXT;
PUSH(XSLT_OP_NS, URL, NULL);
} else {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : Name expected\n");
ctxt->error = 1;
goto error;
PUSH(XSLT_OP_ALL, token, NULL);
goto parse_predicate;
} else {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : QName expected\n");
ctxt->error = 1;
goto error;
xmlFree(token);
token = xsltScanName(ctxt);
if (token == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : QName expected\n");
ctxt->error = 1;
goto error;
}
PUSH(XSLT_OP_ATTR, name, URL);
} else {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : 'child' or 'attribute' expected\n");
ctxt->error = 1;
goto error;
NEXT;
}
if (CUR == 0) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileStepPattern : ']' expected\n");
ctxt->error = 1;
goto error;
xmlChar *name;
name = xsltScanName(ctxt);
if (name == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCompileLocationPathPattern : Name expected\n");
ctxt->error = 1;
return;
int current, start, end, level, j;
if (pattern == NULL) {
- xsltPrintErrorContext(NULL, NULL, node); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, node,
"xsltCompilePattern : NULL pattern\n");
return(NULL);
}
end++;
}
if (current == end) {
- xsltPrintErrorContext(NULL, NULL, node); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, node,
"xsltCompilePattern : NULL pattern\n");
goto error;
}
#endif
xsltCompileLocationPathPattern(ctxt);
if (ctxt->error) {
- xsltPrintErrorContext(NULL, style, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"xsltCompilePattern : failed to compile '%s'\n",
element->pattern);
style->errors++;
current = end;
}
if (end == 0) {
- xsltPrintErrorContext(NULL, NULL, node); /* TODO */
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, node,
"xsltCompilePattern : NULL pattern\n");
style->errors++;
goto error;
break;
case XSLT_OP_END:
case XSLT_OP_PREDICATE:
- xsltPrintErrorContext(NULL, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, NULL,
"xsltAddTemplate: invalid compiled pattern\n");
xsltFreeCompMatch(pat);
return(-1);
list->next = pat;
}
} else {
- xsltPrintErrorContext(NULL, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, NULL,
"xsltAddTemplate: invalid compiled pattern\n");
xsltFreeCompMatch(pat);
return(-1);
cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, NULL,
"xsltNewStylePreComp : malloc failed\n");
style->errors++;
return(NULL);
cur->func = NULL;break;
default:
if (cur->func == NULL) {
- xsltPrintErrorContext(NULL, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, NULL,
"xsltNewStylePreComp : no function for type %d\n", type);
style->errors++;
}
base = xmlNodeGetBase(inst->doc, inst);
URL = xmlBuildURI(filename, base);
if (URL == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltDocumentComp: URL computation failed %s\n", filename);
style->warnings++;
comp->filename = xmlStrdup(filename);
else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
comp->number = 1;
else {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltSortComp: no support for data-type = %s\n", comp->stype);
comp->number = 0; /* use default */
style->warnings++;
else if (xmlStrEqual(comp->order, (const xmlChar *) "descending"))
comp->descending = 1;
else {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltSortComp: invalid value %s for order\n", comp->order);
comp->descending = 0; /* use default */
style->warnings++;
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltSortComp: could not compile select expression '%s'\n",
comp->select);
style->errors++;
comp->noescape = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:text: disable-output-escaping allows only yes or no\n");
style->warnings++;
}
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:copy-of : select is missing\n");
style->errors++;
return;
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:copy-of : could not compile select expression '%s'\n",
comp->select);
style->errors++;
comp->noescape = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:value-of : disable-output-escaping allows only yes or no\n");
style->warnings++;
}
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:value-of : select is missing\n");
style->errors++;
return;
}
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:value-of : could not compile select expression '%s'\n",
comp->select);
style->errors++;
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:with-param : name is missing\n");
style->errors++;
} else {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:param : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
if (inst->children != NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:param : content should be empty since select is present \n");
style->warnings++;
}
xmlStrEqual(prop, BAD_CAST("any"))) {
comp->numdata.level = prop;
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:number : invalid value %s for level\n", prop);
style->warnings++;
xmlFree(prop);
prop = xsltGetNsProp(cur, (const xmlChar *)"letter-value", XSLT_NAMESPACE);
if (prop != NULL) {
if (xmlStrEqual(prop, BAD_CAST("alphabetic"))) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:number : letter-value 'alphabetic' not implemented\n");
style->warnings++;
XSLT_TODO; /* xsl:number letter-value attribute alphabetic */
} else if (xmlStrEqual(prop, BAD_CAST("traditional"))) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:number : letter-value 'traditional' not implemented\n");
style->warnings++;
XSLT_TODO; /* xsl:number letter-value attribute traditional */
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:number : invalid value %s for letter-value\n", prop);
style->warnings++;
}
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:call-template : name is missing\n");
style->errors++;
} else {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:apply-templates : could not compile select expression '%s'\n",
comp->select);
style->errors++;
comp->test = xsltGetNsProp(inst, (const xmlChar *)"test", XSLT_NAMESPACE);
if (comp->test == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:if : test is not defined\n");
style->errors++;
return;
}
comp->comp = xmlXPathCompile(comp->test);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:if : could not compile test expression '%s'\n",
comp->test);
style->errors++;
comp->test = xsltGetNsProp(inst, (const xmlChar *)"test", XSLT_NAMESPACE);
if (comp->test == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:when : test is not defined\n");
style->errors++;
return;
}
comp->comp = xmlXPathCompile(comp->test);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:when : could not compile test expression '%s'\n",
comp->test);
style->errors++;
comp->select = xsltGetNsProp(inst, (const xmlChar *)"select",
XSLT_NAMESPACE);
if (comp->select == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"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,
+ xsltTransformError(NULL, style, inst,
"xsl:for-each : could not compile select expression '%s'\n",
comp->select);
style->errors++;
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:variable : name is missing\n");
style->errors++;
} else {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:variable : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
if (inst->children != NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:variable : content should be empty since select is present \n");
style->warnings++;
}
*/
prop = xsltGetNsProp(inst, (const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:param : name is missing\n");
style->errors++;
} else {
if (comp->select != NULL) {
comp->comp = xmlXPathCompile(comp->select);
if (comp->comp == NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:param : could not compile select expression '%s'\n",
comp->select);
style->errors++;
}
if (inst->children != NULL) {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsl:param : content should be empty since select is present \n");
style->warnings++;
}
inst->_private = (void *) xsltDocumentComp(style, inst,
(xsltTransformFunction) xsltDocumentElem);
} else {
- xsltPrintErrorContext(NULL, style, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, inst,
"xsltStylePreCompute: unknown xsl:%s\n", inst->name);
style->warnings++;
}
ret = (xsltSecurityPrefsPtr) xmlMalloc(sizeof(xsltSecurityPrefs));
if (ret == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewSecurityPrefs : malloc failed\n");
return(NULL);
}
uri = xmlParseURI((const char *)URL);
if (uri == NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltDocumentElem: URL parsing failed for %s\n",
URL);
return(-1);
if (check != NULL) {
ret = check(sec, ctxt, uri->path);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"File write for %s refused\n", URL);
xmlFreeURI(uri);
return(0);
if (check != NULL) {
ret = check(sec, ctxt, directory);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"Directory creation for %s refused\n",
URL);
xmlFree(directory);
if (check != NULL) {
ret = check(sec, ctxt, uri->path);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"File write for %s refused\n", URL);
xmlFreeURI(uri);
return(0);
uri = xmlParseURI((const char *)URL);
if (uri == NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xsltCheckRead: URL parsing failed for %s\n",
URL);
return(-1);
if (check != NULL) {
ret = check(sec, ctxt, uri->path);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"Local file read for %s refused\n", URL);
xmlFreeURI(uri);
return(0);
if (check != NULL) {
ret = check(sec, ctxt, uri->path);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"Network file read for %s refused\n", URL);
xmlFreeURI(uri);
return(0);
ret = res->stringval;
res->stringval = NULL;
} else {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"xpath : string() function didn't return a String\n");
}
xmlXPathFreeObject(res);
/* TODO: this is obviously broken ... the namespaces should be passed too ! */
xmlChar * xsltEvalXPathString (xsltTransformContextPtr ctxt,
xmlXPathCompExprPtr comp);
+xmlChar * xsltEvalXPathStringNs (xsltTransformContextPtr ctxt,
+ xmlXPathCompExprPtr comp,
+ int nsNr,
+ xmlNsPtr *nsList);
xmlNodePtr * xsltTemplateProcess (xsltTransformContextPtr ctxt,
xmlNodePtr node);
xmlAttrPtr attr);
xmlChar * xsltAttrTemplateValueProcess (xsltTransformContextPtr ctxt,
const xmlChar* attr);
+xmlChar * xsltAttrTemplateValueProcessNode(xsltTransformContextPtr ctxt,
+ const xmlChar* str,
+ xmlNodePtr node);
#ifdef __cplusplus
}
#endif
cur = (xsltTransformContextPtr) xmlMalloc(sizeof(xsltTransformContext));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, (xmlNodePtr)doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, (xmlNodePtr)doc,
"xsltNewTransformContext : malloc failed\n");
return(NULL);
}
cur->templTab = (xsltTemplatePtr *)
xmlMalloc(10 * sizeof(xsltTemplatePtr));
if (cur->templTab == NULL) {
- xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
"xsltNewTransformContext: out of memory\n");
xmlFree(cur);
return(NULL);
xmlXPathInit();
cur->xpathCtxt = xmlXPathNewContext(doc);
if (cur->xpathCtxt == NULL) {
- xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
"xsltNewTransformContext : xmlXPathNewContext failed\n");
xmlFree(cur->templTab);
xmlFree(cur->varsTab);
cur->xpathCtxt->nsHash = style->nsHash;
docu = xsltNewDocument(cur, doc);
if (docu == NULL) {
- xsltPrintErrorContext(cur, NULL, (xmlNodePtr)doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(cur, NULL, (xmlNodePtr)doc,
"xsltNewTransformContext : xsltNewDocument failed\n");
xmlFree(cur->templTab);
xmlFree(cur->varsTab);
if (target != NULL)
xmlAddChild(target, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, target);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, target,
"xsltCopyTextString: text copy failed\n");
}
return(copy);
if (target != NULL)
xmlAddChild(target, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, target);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, target,
"xsltCopyText: text copy failed\n");
}
return(copy);
copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
}
} else {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltCopyNode: copy %s failed\n", node->name);
}
return(copy);
if (node->children != NULL)
xsltCopyTreeList(ctxt, node->children, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltCopyTree: copy %s failed\n", node->name);
}
return(copy);
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltDefaultProcessOneNode: cdata copy failed\n");
}
return;
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltDefaultProcessOneNode: text copy failed\n");
}
return;
while ((cur != NULL) && (cur->type != XML_TEXT_NODE))
cur = cur->next;
if (cur == NULL) {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltDefaultProcessOneNode: no text for attribute\n");
} else {
#ifdef WITH_XSLT_DEBUG_PROCESS
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, node);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, node,
"xsltDefaultProcessOneNode: text copy failed\n");
}
}
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsltDefaultProcessOneNode: cdata copy failed\n");
}
}
if (copy != NULL) {
xmlAddChild(ctxt->insert, copy);
} else {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsltDefaultProcessOneNode: text copy failed\n");
}
}
CHECK_STOPPED;
if (ctxt->templNr >= xsltMaxDepth) {
- xsltPrintErrorContext(ctxt, NULL, list);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, list,
"xsltApplyOneTemplate: loop found ???\n");
xsltGenericError(xsltGenericErrorContext,
"try increasing xsltMaxDepth (--maxdepth)\n");
}
if (!found) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsltApplyOneTemplate: failed to find extension %s\n",
cur->name);
}
}
if (URL == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: href/URI-Reference not found\n");
return;
}
}
if (filename == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: URL computation failed for %s\n",
URL);
xmlFree(URL);
if (ctxt->sec != NULL) {
ret = xsltCheckWrite(ctxt->sec, ctxt, filename);
if (ret == 0) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: write rights for %s denied\n",
filename);
xmlFree(URL);
style = xsltNewStylesheet();
if (style == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: out of memory\n");
goto error;
}
(xmlStrEqual(prop, (const xmlChar *) "text"))) {
style->method = prop;
} else {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"invalid value for method: %s\n", prop);
style->warnings++;
}
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->standalone = 0;
} else {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"invalid value for standalone: %s\n",
prop);
style->warnings++;
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->indent = 0;
} else {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"invalid value for indent: %s\n", prop);
style->warnings++;
}
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->omitXmlDeclaration = 0;
} else {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"invalid value for omit-xml-declaration: %s\n",
prop);
style->warnings++;
if (res == NULL)
goto error;
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: unsupported method xhtml, using html\n",
style->method);
ctxt->type = XSLT_OUTPUT_HTML;
if (res == NULL)
goto error;
} else {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: unsupported method %s\n",
style->method);
goto error;
ret = xsltSaveResultToFilename((const char *) filename,
res, style, 0);
if (ret < 0) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: unable to save to %s\n",
filename);
ctxt->state = XSLT_STATE_ERROR;
xmlNodePtr node ATTRIBUTE_UNUSED, xmlNodePtr inst,
xsltStylePreCompPtr comp) {
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:sort : compilation failed\n");
return;
}
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:sort : improper use this should not be reached\n");
}
while (text != NULL) {
if ((text->type != XML_TEXT_NODE) &&
(text->type != XML_CDATA_SECTION_NODE)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:text content problem\n");
break;
}
prop = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)"name", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:element : name is missing\n");
goto error;
}
}
oldns = xmlSearchNs(inst->doc, inst, prefix);
if (oldns == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:element : no namespace bound to prefix %s\n", prefix);
} else {
ns = xsltGetNamespace(ctxt, inst, ns, ctxt->insert);
copy = xmlNewDocNode(ctxt->output, ns, name, NULL);
if (copy == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:element : creation of %s failed\n", name);
goto error;
}
ncname = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *)"name", XSLT_NAMESPACE);
if (ncname == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:processing-instruction : name is missing\n");
goto error;
}
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:copy-of : compilation failed\n");
return;
}
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:value-of : compilation failed\n");
return;
}
}
if (copy == NULL) {
if ((res == NULL) || (res->stringval != NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsltValueOf: text copy failed\n");
}
}
xmlNodePtr inst, xsltStylePreCompPtr comp)
{
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:number : compilation failed\n");
return;
}
xsltTemplatePtr template;
if ((ctxt->templ == NULL) || (ctxt->templ->style == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:apply-imports : internal error no current template\n");
return;
}
if (ctxt->insert == NULL)
return;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:call-template : compilation failed\n");
return;
}
if (comp->templ == NULL) {
comp->templ = xsltFindTemplate(ctxt, comp->name, comp->ns);
if (comp->templ == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:call-template : template %s not found\n", comp->name);
return;
}
xmlNsPtr *oldNamespaces;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:apply-templates : compilation failed\n");
return;
}
if (comp->select != NULL) {
if (comp->comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:apply-templates : compilation failed\n");
goto error;
}
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,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:apply-templates : can't find doc\n");
goto error;
}
*/
replacement = inst->children;
if (replacement == NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"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,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:choose: xsl:when expected first\n");
goto error;
}
xsltStylePreCompPtr wcomp = replacement->_private;
if ((wcomp == NULL) || (wcomp->test == NULL) || (wcomp->comp == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:choose: compilation failed !\n");
goto error;
}
replacement = replacement->next;
}
if (replacement != NULL) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:choose: unexpected content %s\n", replacement->name);
goto error;
}
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->test == NULL) || (comp->comp == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:if : compilation failed\n");
return;
}
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
if ((comp == NULL) || (comp->select == NULL) || (comp->comp == NULL)) {
- xsltPrintErrorContext(ctxt, NULL, inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:for-each : compilation failed\n");
return;
}
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,
+ xsltTransformError(ctxt, NULL, inst,
"xsl:for-each : can't find doc\n");
goto error;
}
if (res == NULL)
goto error;
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
- xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
"xsltApplyStylesheetInternal: unsupported method xhtml, using html\n",
style->method);
ctxt->type = XSLT_OUTPUT_HTML;
if (res == NULL)
goto error;
} else {
- xsltPrintErrorContext(ctxt, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
"xsltApplyStylesheetInternal: unsupported method %s\n",
style->method);
goto error;
tmp = xsltApplyStylesheetInternal(style, doc, params, output, profile,
userCtxt);
if (tmp == NULL) {
- xsltPrintErrorContext(NULL, NULL, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, (xmlNodePtr) doc,
"xsltRunStylesheet : run failed\n");
return (-1);
}
cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewStackElem : malloc failed\n");
return(NULL);
}
cur = (xsltStackElemPtr) xmlMalloc(sizeof(xsltStackElem));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltCopyStackElem : malloc failed\n");
return(NULL);
}
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
- xsltPrintErrorContext(ctxt, NULL, precomp->inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, precomp->inst,
"Evaluating variable %s failed\n", elem->name);
ctxt->state = XSLT_STATE_STOPPED;
#ifdef WITH_XSLT_DEBUG_VARIABLE
if ((precomp == NULL) || (precomp->comp == NULL))
xmlXPathFreeCompExpr(comp);
if (result == NULL) {
- xsltPrintErrorContext(ctxt, NULL, precomp->inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, precomp->inst,
"Evaluating global variable %s failed\n", elem->name);
ctxt->state = XSLT_STATE_STOPPED;
#ifdef WITH_XSLT_DEBUG_VARIABLE
if ((elem->comp->inst != NULL) &&
(def->comp != NULL) && (def->comp->inst != NULL) &&
(elem->comp->inst->doc == def->comp->inst->doc)) {
- xsltPrintErrorContext(ctxt, style, elem->comp->inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, style, elem->comp->inst,
"Global variable %s already defined\n", elem->name);
}
}
ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
prefix);
if (ns == NULL) {
- xsltPrintErrorContext(ctxt, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, style, NULL,
"user param : no namespace bound to prefix %s\n", prefix);
href = NULL;
} else {
xmlXPathFreeCompExpr(comp);
}
if (result == NULL) {
- xsltPrintErrorContext(ctxt, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, style, NULL,
"Evaluating user parameter %s failed\n", name);
ctxt->state = XSLT_STATE_STOPPED;
xmlFree(ncname);
res = xmlHashAddEntry2(ctxt->globalVars, ncname, href, elem);
if (res != 0) {
xsltFreeStackElem(elem);
- xsltPrintErrorContext(ctxt, style, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, style, NULL,
"Global parameter %s already defined\n", ncname);
}
xmlFree(ncname);
if (xsltCheckStackElem(ctxt, comp->name, comp->ns) != 0) {
if (!param) {
- xsltPrintErrorContext(ctxt, NULL, comp->inst);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, comp->inst,
"xsl:variable : redefining %s\n", comp->name);
}
#ifdef WITH_XSLT_DEBUG_VARIABLE
return(NULL);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:param : compilation error\n");
return(NULL);
}
if (comp->name == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:param : missing name attribute\n");
return(NULL);
}
xsltStylePreCompute(style, cur);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:variable : compilation failed\n");
return;
}
if (comp->name == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:variable : missing name attribute\n");
return;
}
xsltStylePreCompute(style, cur);
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:param : compilation failed\n");
return;
}
if (comp->name == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:param : missing name attribute\n");
return;
}
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:variable : compilation failed\n");
return;
}
if (comp->name == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:variable : missing name attribute\n");
return;
}
comp = (xsltStylePreCompPtr) cur->_private;
if (comp == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:param : compilation failed\n");
return;
}
if (comp->name == NULL) {
- xsltPrintErrorContext(ctxt, NULL, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, cur,
"xsl:param : missing name attribute\n");
return;
}
context = (xsltTransformContextPtr) ctxt;
ret = xsltVariableLookup(context, name, ns_uri);
if (ret == NULL) {
- xsltPrintErrorContext(ctxt, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, NULL,
"unregistered variable %s\n", name);
}
#ifdef WITH_XSLT_DEBUG_VARIABLE
cur = (xsltTemplatePtr) xmlMalloc(sizeof(xsltTemplate));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewTemplate : malloc failed\n");
return(NULL);
}
cur = (xsltStylesheetPtr) xmlMalloc(sizeof(xsltStylesheet));
if (cur == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltNewStylesheet : malloc failed\n");
return(NULL);
}
(xmlStrEqual(prop, (const xmlChar *) "text"))) {
style->method = prop;
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"invalid value for method: %s\n", prop);
style->warnings++;
}
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->standalone = 0;
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"invalid value for standalone: %s\n", prop);
style->warnings++;
}
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->indent = 0;
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"invalid value for indent: %s\n", prop);
style->warnings++;
}
} else if (xmlStrEqual(prop, (const xmlChar *) "no")) {
style->omitXmlDeclaration = 0;
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"invalid value for omit-xml-declaration: %s\n",
prop);
style->warnings++;
if (prop != NULL) {
format = xsltDecimalFormatGetByName(style, prop);
if (format != NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylestyleDecimalFormat: %s already exists\n", prop);
style->warnings++;
return;
}
format = xsltNewDecimalFormat(prop);
if (format == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylestyleDecimalFormat: failed creating new decimal-format\n");
style->errors++;
return;
elements = xsltGetNsProp(cur, (const xmlChar *)"elements", XSLT_NAMESPACE);
if (elements == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylesheetPreserveSpace: missing elements attribute\n");
style->warnings++;
return;
else
ns = xmlSearchNs(style->doc, cur, prefix);
if (ns == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:extension-element-prefix : undefined namespace %s\n",
prefix);
style->warnings++;
elements = xsltGetNsProp(cur, (const xmlChar *)"elements", XSLT_NAMESPACE);
if (elements == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylesheetStripSpace: missing elements attribute\n");
style->warnings++;
return;
else
ns = xmlSearchNs(style->doc, cur, prefix);
if (ns == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:exclude-result-prefixes : undefined namespace %s\n",
prefix);
style->warnings++;
if (style->nsHash == NULL) {
style->nsHash = xmlHashCreate(10);
if (style->nsHash == NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltGatherNamespaces: failed to create hash table\n");
style->errors++;
return;
}
URI = xmlHashLookup(style->nsHash, ns->prefix);
if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"Namespaces prefix %s used for multiple namespaces\n");
style->warnings++;
} else if (URI == NULL) {
noesc = 1;
} else if (!xmlStrEqual(prop,
(const xmlChar *)"no")){
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsl:text: disable-output-escaping allows only yes or no\n");
style->warnings++;
while (text != NULL) {
if ((text->type != XML_TEXT_NODE) &&
(text->type != XML_CDATA_SECTION_NODE)) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseTemplateContent: xslt:text content problem\n");
style->errors++;
break;
xmlNodePtr param = cur;
cur = cur->next;
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseTemplateContent: ignoring misplaced param element\n");
style->warnings++;
xmlUnlinkNode(param);
"xsltParseStylesheetKey: name %s\n", name);
#endif
} else {
- xsltPrintErrorContext(NULL, style, key);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, key,
"xsl:key : error missing name\n");
style->errors++;
goto error;
match = xsltGetNsProp(key, (const xmlChar *)"match", XSLT_NAMESPACE);
if (match == NULL) {
- xsltPrintErrorContext(NULL, style, key);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, key,
"xsl:key : error missing match\n");
style->errors++;
goto error;
use = xsltGetNsProp(key, (const xmlChar *)"use", XSLT_NAMESPACE);
if (use == NULL) {
- xsltPrintErrorContext(NULL, style, key);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, key,
"xsl:key : error missing use\n");
style->errors++;
goto error;
prop = xsltGetNsProp(top, (const xmlChar *)"version", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, style, top);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, top,
"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,
+ xsltTransformError(NULL, style, top,
"xsl:version: only 1.0 features are supported\n");
/* TODO set up compatibility when not XSLT 1.0 */
style->warnings++;
}
if (cur->type == XML_TEXT_NODE) {
if (cur->content != NULL) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"misplaced text element: '%s'\n", cur->content);
}
style->errors++;
continue;
}
if (IS_XSLT_NAME(cur, "import")) {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: ignoring misplaced import element\n");
style->errors++;
} else if (IS_XSLT_NAME(cur, "include")) {
} else if (IS_XSLT_NAME(cur, "namespace-alias")) {
xsltNamespaceAlias(style, cur);
} else {
- xsltPrintErrorContext(NULL, style, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, style, cur,
"xsltParseStylesheetTop: ignoring unknown %s element\n",
cur->name);
style->warnings++;
*/
cur = xmlDocGetRootElement(doc);
if (cur == NULL) {
- xsltPrintErrorContext(NULL, ret, (xmlNodePtr) doc);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, ret, (xmlNodePtr) doc,
"xsltParseStylesheetProcess : empty stylesheet\n");
return(NULL);
}
*/
prop = xsltGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
if (prop == NULL) {
- xsltPrintErrorContext(NULL, ret, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, ret, cur,
"xsltParseStylesheetProcess : document is not a stylesheet\n");
return(NULL);
}
#endif
if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) {
- xsltPrintErrorContext(NULL, ret, cur);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, ret, cur,
"xsl:version: only 1.0 features are supported\n");
/* TODO set up compatibility when not XSLT 1.0 */
ret->warnings++;
res = xsltCheckRead(sec, NULL, filename);
if (res == 0) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltParseStylesheetFile: read rights for %s denied\n",
filename);
return(NULL);
doc = xmlParseFile((const char *) filename);
if (doc == NULL) {
- xsltPrintErrorContext(NULL, NULL, NULL);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, NULL,
"xsltParseStylesheetFile : cannot parse %s\n", filename);
return(NULL);
}
#endif
URI = xmlParseURI((const char *) href);
if (URI == NULL) {
- xsltPrintErrorContext(NULL, NULL, child);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, child,
"xml-stylesheet : href %s is not valid\n", href);
xmlFree(href);
return(NULL);
else
ID = xmlGetID(doc, (const xmlChar *) URI->fragment);
if (ID == NULL) {
- xsltPrintErrorContext(NULL, NULL, child);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(NULL, NULL, child,
"xml-stylesheet : no ID %s found\n", URI->fragment);
} else {
xmlDocPtr fake;
xsltDocumentPtr styleList; /* the stylesheet docs list */
void * sec; /* the security preferences if any */
+
+ xmlGenericErrorFunc error; /* a specific error handler */
+ void * errctx; /* context for the error handler */
};
/**
* *
************************************************************************/
+#define XSLT_GET_VAR_STR(msg, str) { \
+ int size; \
+ int chars; \
+ char *larger; \
+ va_list ap; \
+ \
+ str = (char *) xmlMalloc(150); \
+ if (str == NULL) \
+ return; \
+ \
+ size = 150; \
+ \
+ while (1) { \
+ va_start(ap, msg); \
+ chars = vsnprintf(str, size, msg, ap); \
+ va_end(ap); \
+ if ((chars > -1) && (chars < size)) \
+ break; \
+ if (chars > -1) \
+ size += chars + 1; \
+ else \
+ size += 100; \
+ if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\
+ xmlFree(str); \
+ return; \
+ } \
+ str = larger; \
+ } \
+}
/**
* xsltGenericErrorDefaultFunc:
* @ctx: an error context
const xmlChar *file = NULL;
const xmlChar *name = NULL;
const char *type = "error";
+ xmlGenericErrorFunc error = xsltGenericError;
+ void *errctx = xsltGenericErrorContext;
- if (ctxt != NULL)
+ if (ctxt != NULL) {
ctxt->state = XSLT_STATE_ERROR;
+ if (ctxt->error != NULL) {
+ error = ctxt->error;
+ errctx = ctxt->errctx;
+ }
+ }
if ((node == NULL) && (ctxt != NULL))
node = ctxt->inst;
type = "compilation error";
if ((file != NULL) && (line != 0) && (name != NULL))
- xsltGenericError(xsltGenericErrorContext,
- "%s: file %s line %d element %s\n",
- type, file, line, name);
+ error(errctx, "%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);
+ error(errctx, "%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);
+ error(errctx, "%s: file %s line %d\n", type, file, line);
else if (file != NULL)
- xsltGenericError(xsltGenericErrorContext,
- "%s: file %s\n",
- type, file);
+ error(errctx, "%s: file %s\n", type, file);
else if (name != NULL)
- xsltGenericError(xsltGenericErrorContext,
- "%s: element %s\n",
- type, name);
+ error(errctx, "%s: element %s\n", type, name);
else
- xsltGenericError(xsltGenericErrorContext,
- "%s\n",
- type);
+ error(errctx, "%s\n", type);
+}
+
+/**
+ * xsltSetTransformErrorFunc:
+ * @ctxt: the XSLT transformation context
+ * @ctx: the new error handling context
+ * @handler: the new handler function
+ *
+ * Function to reset the handler and the error context for out of
+ * context error messages specific to a given XSLT transromation.
+ *
+ * This simply means that @handler will be called for subsequent
+ * error messages while running the transformation.
+ */
+void
+xsltSetTransformErrorFunc(xsltTransformContextPtr ctxt,
+ void *ctx, xmlGenericErrorFunc handler)
+{
+ ctxt->error = handler;
+ ctxt->errctx = ctx;
+}
+
+/**
+ * xsltTransformError:
+ * @ctxt: an XSLT transformation context
+ * @msg: the message to display/transmit
+ * @...: extra parameters for the message display
+ *
+ * Display and format an error messages, gives file, line, position and
+ * extra parameters, will use the specific transformation context if available
+ */
+void
+xsltTransformError(xsltTransformContextPtr ctxt,
+ xsltStylesheetPtr style,
+ xmlNodePtr node,
+ const char *msg, ...) {
+ xmlGenericErrorFunc error = xsltGenericError;
+ void *errctx = xsltGenericErrorContext;
+ char * str;
+
+ if (ctxt != NULL) {
+ ctxt->state = XSLT_STATE_ERROR;
+ if (ctxt->error != NULL) {
+ error = ctxt->error;
+ errctx = ctxt->errctx;
+ }
+ }
+ if ((node == NULL) && (ctxt != NULL))
+ node = ctxt->inst;
+ xsltPrintErrorContext(ctxt, style, node);
+ XSLT_GET_VAR_STR(msg, str);
+ error(errctx, "%s", str);
+ if (str != NULL)
+ xmlFree(str);
}
/************************************************************************
else if (xmlStrEqual(comp->stype, (const xmlChar *) "number"))
comp->number = 1;
else {
- xsltPrintErrorContext(ctxt, NULL, sorts[j]);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, sorts[j],
"xsltDoSortFunction: no support for data-type = %s\n",
comp->stype);
comp->number = 0; /* use default */
(const xmlChar *) "descending"))
comp->descending = 1;
else {
- xsltPrintErrorContext(ctxt, NULL, sorts[j]);
- xsltGenericError(xsltGenericErrorContext,
+ xsltTransformError(ctxt, NULL, sorts[j],
"xsltDoSortFunction: invalid value %s for order\n",
comp->order);
comp->descending = 0; /* use default */
xmlGenericErrorFunc handler);
void xsltSetGenericDebugFunc (void *ctx,
xmlGenericErrorFunc handler);
+void xsltSetTransformErrorFunc (xsltTransformContextPtr ctxt,
+ void *ctx,
+ xmlGenericErrorFunc handler);
+void xsltTransformError (xsltTransformContextPtr ctxt,
+ xsltStylesheetPtr style,
+ xmlNodePtr node,
+ const char *msg,
+ ...);
/*
* Sorting.