Use xsl:element for document element to prevent ns
[yazproxy-moved-to-github.git] / src / p2_xmlerror.cpp
1 /* $Id: p2_xmlerror.cpp,v 1.1 2005-10-05 12:07:15 adam Exp $
2    Copyright (c) 1998-2005, Index Data.
3
4 This file is part of the yaz-proxy.
5
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
9 version.
10
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE.  If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA.
20  */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <yaz/log.h>
25
26 #include "p2_xmlerror.h"
27
28 #if HAVE_XSLT
29 #include <libxml/parser.h>
30 #include <libxslt/xsltutils.h>
31 #endif
32
33 #if HAVE_XSLT
34 static void p2_xml_error_handler(void *ctx, const char *fmt, ...)
35 {
36     char buf[1024];
37     size_t sz;
38
39     va_list ap;
40     va_start(ap, fmt);
41
42 #ifdef WIN32
43     vsprintf(buf, fmt, ap);
44 #else
45     vsnprintf(buf, sizeof(buf), fmt, ap);
46 #endif
47     sz = strlen(buf);
48     if (sz > 0 && buf[sz-1] == '\n')
49         buf[sz-1] = '\0';
50         
51     yaz_log(YLOG_WARN, "%s: %s", (char*) ctx, buf);
52
53     va_end (ap);
54 }
55 #endif
56
57 void p2_xmlerror_setup()
58 {
59 #if HAVE_XSLT
60     xmlSetGenericErrorFunc((void *) "XML", p2_xml_error_handler);
61     xsltSetGenericErrorFunc((void *) "XSLT", p2_xml_error_handler);
62 #endif
63 }
64 /*
65  * Local variables:
66  * c-basic-offset: 4
67  * indent-tabs-mode: nil
68  * End:
69  * vim: shiftwidth=4 tabstop=8 expandtab
70  */