Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * error.c: module displaying/handling XML parser errors |
| 3 | * |
| 4 | * See Copyright for the status of this software. |
| 5 | * |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 6 | * Daniel Veillard <daniel@veillard.com> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
Daniel Veillard | 34ce8be | 2002-03-18 19:37:11 +0000 | [diff] [blame] | 9 | #define IN_LIBXML |
Bjorn Reese | 70a9da5 | 2001-04-21 16:57:29 +0000 | [diff] [blame] | 10 | #include "libxml.h" |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 11 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 12 | #include <stdarg.h> |
| 13 | #include <libxml/parser.h> |
| 14 | #include <libxml/xmlerror.h> |
Daniel Veillard | e356c28 | 2001-03-10 12:32:04 +0000 | [diff] [blame] | 15 | #include <libxml/xmlmemory.h> |
Daniel Veillard | 3c01b1d | 2001-10-17 15:58:35 +0000 | [diff] [blame] | 16 | #include <libxml/globals.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 17 | |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 18 | void xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED, |
| 19 | const char *msg, |
| 20 | ...); |
| 21 | |
Daniel Veillard | 1c43dbf | 2001-06-05 17:12:52 +0000 | [diff] [blame] | 22 | #define XML_GET_VAR_STR(msg, str) { \ |
| 23 | int size; \ |
| 24 | int chars; \ |
| 25 | char *larger; \ |
| 26 | va_list ap; \ |
| 27 | \ |
| 28 | str = (char *) xmlMalloc(150); \ |
| 29 | if (str == NULL) \ |
| 30 | return; \ |
| 31 | \ |
| 32 | size = 150; \ |
| 33 | \ |
| 34 | while (1) { \ |
| 35 | va_start(ap, msg); \ |
| 36 | chars = vsnprintf(str, size, msg, ap); \ |
| 37 | va_end(ap); \ |
| 38 | if ((chars > -1) && (chars < size)) \ |
| 39 | break; \ |
| 40 | if (chars > -1) \ |
| 41 | size += chars + 1; \ |
| 42 | else \ |
| 43 | size += 100; \ |
| 44 | if ((larger = (char *) xmlRealloc(str, size)) == NULL) {\ |
| 45 | xmlFree(str); \ |
| 46 | return; \ |
| 47 | } \ |
| 48 | str = larger; \ |
| 49 | } \ |
| 50 | } |
Bjorn Reese | 570ff08 | 2001-06-05 12:45:55 +0000 | [diff] [blame] | 51 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 52 | /************************************************************************ |
| 53 | * * |
| 54 | * Handling of out of context errors * |
| 55 | * * |
| 56 | ************************************************************************/ |
| 57 | |
| 58 | /** |
| 59 | * xmlGenericErrorDefaultFunc: |
| 60 | * @ctx: an error context |
| 61 | * @msg: the message to display/transmit |
| 62 | * @...: extra parameters for the message display |
| 63 | * |
| 64 | * Default handler for out of context error messages. |
| 65 | */ |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 66 | void |
Daniel Veillard | c86a4fa | 2001-03-26 16:28:29 +0000 | [diff] [blame] | 67 | xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) { |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 68 | va_list args; |
| 69 | |
| 70 | if (xmlGenericErrorContext == NULL) |
| 71 | xmlGenericErrorContext = (void *) stderr; |
| 72 | |
| 73 | va_start(args, msg); |
| 74 | vfprintf((FILE *)xmlGenericErrorContext, msg, args); |
| 75 | va_end(args); |
| 76 | } |
| 77 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 78 | /** |
| 79 | * initGenericErrorDefaultFunc: |
| 80 | * @handler: the handler |
| 81 | * |
| 82 | * Set or reset (if NULL) the default handler for generic errors |
Daniel Veillard | 7424eb6 | 2003-01-24 14:14:52 +0000 | [diff] [blame] | 83 | * to the builtin error function. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 84 | */ |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 85 | void |
Daniel Veillard | db5850a | 2002-01-18 11:49:26 +0000 | [diff] [blame] | 86 | initGenericErrorDefaultFunc(xmlGenericErrorFunc * handler) |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 87 | { |
Daniel Veillard | db5850a | 2002-01-18 11:49:26 +0000 | [diff] [blame] | 88 | if (handler == NULL) |
| 89 | xmlGenericError = xmlGenericErrorDefaultFunc; |
| 90 | else |
| 91 | (*handler) = xmlGenericErrorDefaultFunc; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 92 | } |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * xmlSetGenericErrorFunc: |
| 96 | * @ctx: the new error handling context |
| 97 | * @handler: the new handler function |
| 98 | * |
| 99 | * Function to reset the handler and the error context for out of |
| 100 | * context error messages. |
| 101 | * This simply means that @handler will be called for subsequent |
| 102 | * error messages while not parsing nor validating. And @ctx will |
| 103 | * be passed as first argument to @handler |
| 104 | * One can simply force messages to be emitted to another FILE * than |
| 105 | * stderr by setting @ctx to this file handle and @handler to NULL. |
| 106 | */ |
| 107 | void |
| 108 | xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) { |
| 109 | xmlGenericErrorContext = ctx; |
| 110 | if (handler != NULL) |
| 111 | xmlGenericError = handler; |
| 112 | else |
| 113 | xmlGenericError = xmlGenericErrorDefaultFunc; |
| 114 | } |
| 115 | |
| 116 | /************************************************************************ |
| 117 | * * |
| 118 | * Handling of parsing errors * |
| 119 | * * |
| 120 | ************************************************************************/ |
| 121 | |
| 122 | /** |
| 123 | * xmlParserPrintFileInfo: |
| 124 | * @input: an xmlParserInputPtr input |
| 125 | * |
| 126 | * Displays the associated file and line informations for the current input |
| 127 | */ |
| 128 | |
| 129 | void |
| 130 | xmlParserPrintFileInfo(xmlParserInputPtr input) { |
| 131 | if (input != NULL) { |
| 132 | if (input->filename) |
| 133 | xmlGenericError(xmlGenericErrorContext, |
| 134 | "%s:%d: ", input->filename, |
| 135 | input->line); |
| 136 | else |
| 137 | xmlGenericError(xmlGenericErrorContext, |
| 138 | "Entity: line %d: ", input->line); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * xmlParserPrintFileContext: |
| 144 | * @input: an xmlParserInputPtr input |
| 145 | * |
| 146 | * Displays current context within the input content for error tracking |
| 147 | */ |
| 148 | |
| 149 | void |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 150 | xmlParserPrintFileContext(xmlParserInputPtr input) { |
| 151 | const xmlChar *cur, *base; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 152 | int n, col; |
| 153 | xmlChar content[81]; /* space for 80 chars + line terminator */ |
Daniel Veillard | 2be3064 | 2001-03-27 00:32:28 +0000 | [diff] [blame] | 154 | xmlChar *ctnt; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 155 | |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 156 | if (input == NULL) return; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 157 | cur = input->cur; |
| 158 | base = input->base; |
Daniel Veillard | 2be3064 | 2001-03-27 00:32:28 +0000 | [diff] [blame] | 159 | /* skip backwards over any end-of-lines */ |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 160 | while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) { |
| 161 | cur--; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 162 | } |
| 163 | n = 0; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 164 | /* search backwards for beginning-of-line (to max buff size) */ |
| 165 | while ((n++ < sizeof(content)-1) && (cur > base) && (*cur != '\n') && (*cur != '\r')) |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 166 | cur--; |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 167 | if ((*cur == '\n') || (*cur == '\r')) cur++; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 168 | /* calculate the error position in terms of the current position */ |
| 169 | col = input->cur - cur; |
| 170 | /* search forward for end-of-line (to max buff size) */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 171 | n = 0; |
Daniel Veillard | 2be3064 | 2001-03-27 00:32:28 +0000 | [diff] [blame] | 172 | ctnt = content; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 173 | /* copy selected text to our buffer */ |
| 174 | while ((*cur != 0) && (*cur != '\n') && (*cur != '\r') && (n < sizeof(content)-1)) { |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 175 | *ctnt++ = *cur++; |
| 176 | n++; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 177 | } |
Daniel Veillard | 2be3064 | 2001-03-27 00:32:28 +0000 | [diff] [blame] | 178 | *ctnt = 0; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 179 | /* print out the selected text */ |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 180 | xmlGenericError(xmlGenericErrorContext,"%s\n", content); |
Daniel Veillard | 2be3064 | 2001-03-27 00:32:28 +0000 | [diff] [blame] | 181 | /* create blank line with problem pointer */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 182 | n = 0; |
Daniel Veillard | 7533cc8 | 2001-04-24 15:52:00 +0000 | [diff] [blame] | 183 | ctnt = content; |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 184 | /* (leave buffer space for pointer + line terminator) */ |
| 185 | while ((n<col) && (n++ < sizeof(content)-2) && (*ctnt != 0)) { |
| 186 | if (*ctnt!='\t') |
| 187 | *ctnt = ' '; |
| 188 | *ctnt++; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 189 | } |
William M. Brack | 3dd57f7 | 2003-05-13 02:06:18 +0000 | [diff] [blame] | 190 | *ctnt++ = '^'; |
| 191 | *ctnt = 0; |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 192 | xmlGenericError(xmlGenericErrorContext,"%s\n", content); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 193 | } |
| 194 | |
Daniel Veillard | 561b7f8 | 2002-03-20 21:55:57 +0000 | [diff] [blame] | 195 | #if 0 |
| 196 | /** |
| 197 | * xmlGetVarStr: |
| 198 | * @msg: the message format |
| 199 | * @args: a va_list argument list |
| 200 | * |
| 201 | * SGS contribution |
| 202 | * Get an arbitrary-sized string for an error argument |
| 203 | * The caller must free() the returned string |
| 204 | */ |
| 205 | static char * |
| 206 | xmlGetVarStr(const char * msg, va_list args) { |
| 207 | int size; |
| 208 | int length; |
| 209 | int chars, left; |
| 210 | char *str, *larger; |
| 211 | va_list ap; |
| 212 | |
| 213 | str = (char *) xmlMalloc(150); |
| 214 | if (str == NULL) |
| 215 | return(NULL); |
| 216 | |
| 217 | size = 150; |
| 218 | length = 0; |
| 219 | |
| 220 | while (1) { |
| 221 | left = size - length; |
| 222 | /* Try to print in the allocated space. */ |
| 223 | va_start(msg, ap); |
| 224 | chars = vsnprintf(str + length, left, msg, ap); |
| 225 | va_end(ap); |
| 226 | /* If that worked, we're done. */ |
| 227 | if ((chars > -1) && (chars < left )) |
| 228 | break; |
| 229 | /* Else try again with more space. */ |
| 230 | if (chars > -1) /* glibc 2.1 */ |
| 231 | size += chars + 1; /* precisely what is needed */ |
| 232 | else /* glibc 2.0 */ |
| 233 | size += 100; |
| 234 | if ((larger = (char *) xmlRealloc(str, size)) == NULL) { |
| 235 | xmlFree(str); |
| 236 | return(NULL); |
| 237 | } |
| 238 | str = larger; |
| 239 | } |
| 240 | return(str); |
| 241 | } |
| 242 | #endif |
| 243 | |
Daniel Veillard | e356c28 | 2001-03-10 12:32:04 +0000 | [diff] [blame] | 244 | /** |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 245 | * xmlParserError: |
| 246 | * @ctx: an XML parser context |
| 247 | * @msg: the message to display/transmit |
| 248 | * @...: extra parameters for the message display |
| 249 | * |
| 250 | * Display and format an error messages, gives file, line, position and |
| 251 | * extra parameters. |
| 252 | */ |
| 253 | void |
| 254 | xmlParserError(void *ctx, const char *msg, ...) |
| 255 | { |
| 256 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 257 | xmlParserInputPtr input = NULL; |
| 258 | xmlParserInputPtr cur = NULL; |
Daniel Veillard | e356c28 | 2001-03-10 12:32:04 +0000 | [diff] [blame] | 259 | char * str; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 260 | |
| 261 | if (ctxt != NULL) { |
| 262 | input = ctxt->input; |
| 263 | if ((input != NULL) && (input->filename == NULL) && |
| 264 | (ctxt->inputNr > 1)) { |
| 265 | cur = input; |
| 266 | input = ctxt->inputTab[ctxt->inputNr - 2]; |
| 267 | } |
| 268 | xmlParserPrintFileInfo(input); |
| 269 | } |
| 270 | |
| 271 | xmlGenericError(xmlGenericErrorContext, "error: "); |
Daniel Veillard | 1c43dbf | 2001-06-05 17:12:52 +0000 | [diff] [blame] | 272 | XML_GET_VAR_STR(msg, str); |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 273 | xmlGenericError(xmlGenericErrorContext, "%s", str); |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 274 | if (str != NULL) |
| 275 | xmlFree(str); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 276 | |
| 277 | if (ctxt != NULL) { |
| 278 | xmlParserPrintFileContext(input); |
| 279 | if (cur != NULL) { |
| 280 | xmlParserPrintFileInfo(cur); |
| 281 | xmlGenericError(xmlGenericErrorContext, "\n"); |
| 282 | xmlParserPrintFileContext(cur); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * xmlParserWarning: |
| 289 | * @ctx: an XML parser context |
| 290 | * @msg: the message to display/transmit |
| 291 | * @...: extra parameters for the message display |
| 292 | * |
| 293 | * Display and format a warning messages, gives file, line, position and |
| 294 | * extra parameters. |
| 295 | */ |
| 296 | void |
| 297 | xmlParserWarning(void *ctx, const char *msg, ...) |
| 298 | { |
| 299 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 300 | xmlParserInputPtr input = NULL; |
| 301 | xmlParserInputPtr cur = NULL; |
Daniel Veillard | e356c28 | 2001-03-10 12:32:04 +0000 | [diff] [blame] | 302 | char * str; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 303 | |
| 304 | if (ctxt != NULL) { |
| 305 | input = ctxt->input; |
| 306 | if ((input != NULL) && (input->filename == NULL) && |
| 307 | (ctxt->inputNr > 1)) { |
| 308 | cur = input; |
| 309 | input = ctxt->inputTab[ctxt->inputNr - 2]; |
| 310 | } |
| 311 | xmlParserPrintFileInfo(input); |
| 312 | } |
| 313 | |
| 314 | xmlGenericError(xmlGenericErrorContext, "warning: "); |
Daniel Veillard | 1c43dbf | 2001-06-05 17:12:52 +0000 | [diff] [blame] | 315 | XML_GET_VAR_STR(msg, str); |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 316 | xmlGenericError(xmlGenericErrorContext, "%s", str); |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 317 | if (str != NULL) |
| 318 | xmlFree(str); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 319 | |
| 320 | if (ctxt != NULL) { |
| 321 | xmlParserPrintFileContext(input); |
| 322 | if (cur != NULL) { |
| 323 | xmlParserPrintFileInfo(cur); |
| 324 | xmlGenericError(xmlGenericErrorContext, "\n"); |
| 325 | xmlParserPrintFileContext(cur); |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | /************************************************************************ |
| 331 | * * |
| 332 | * Handling of validation errors * |
| 333 | * * |
| 334 | ************************************************************************/ |
| 335 | |
| 336 | /** |
| 337 | * xmlParserValidityError: |
| 338 | * @ctx: an XML parser context |
| 339 | * @msg: the message to display/transmit |
| 340 | * @...: extra parameters for the message display |
| 341 | * |
| 342 | * Display and format an validity error messages, gives file, |
| 343 | * line, position and extra parameters. |
| 344 | */ |
| 345 | void |
| 346 | xmlParserValidityError(void *ctx, const char *msg, ...) |
| 347 | { |
| 348 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 349 | xmlParserInputPtr input = NULL; |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 350 | char * str; |
Daniel Veillard | 7657576 | 2002-09-05 14:21:15 +0000 | [diff] [blame] | 351 | int len = xmlStrlen((const xmlChar *) msg); |
| 352 | static int had_info = 0; |
| 353 | int need_context = 0; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 354 | |
Daniel Veillard | 7657576 | 2002-09-05 14:21:15 +0000 | [diff] [blame] | 355 | if ((len > 1) && (msg[len - 2] != ':')) { |
| 356 | if (ctxt != NULL) { |
| 357 | input = ctxt->input; |
| 358 | if ((input->filename == NULL) && (ctxt->inputNr > 1)) |
| 359 | input = ctxt->inputTab[ctxt->inputNr - 2]; |
| 360 | |
| 361 | if (had_info == 0) { |
| 362 | xmlParserPrintFileInfo(input); |
| 363 | } |
| 364 | } |
| 365 | xmlGenericError(xmlGenericErrorContext, "validity error: "); |
| 366 | need_context = 1; |
| 367 | had_info = 0; |
| 368 | } else { |
| 369 | had_info = 1; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 370 | } |
| 371 | |
Daniel Veillard | 1c43dbf | 2001-06-05 17:12:52 +0000 | [diff] [blame] | 372 | XML_GET_VAR_STR(msg, str); |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 373 | xmlGenericError(xmlGenericErrorContext, "%s", str); |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 374 | if (str != NULL) |
| 375 | xmlFree(str); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 376 | |
Daniel Veillard | 7657576 | 2002-09-05 14:21:15 +0000 | [diff] [blame] | 377 | if ((ctxt != NULL) && (input != NULL)) { |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 378 | xmlParserPrintFileContext(input); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | /** |
| 383 | * xmlParserValidityWarning: |
| 384 | * @ctx: an XML parser context |
| 385 | * @msg: the message to display/transmit |
| 386 | * @...: extra parameters for the message display |
| 387 | * |
| 388 | * Display and format a validity warning messages, gives file, line, |
| 389 | * position and extra parameters. |
| 390 | */ |
| 391 | void |
| 392 | xmlParserValidityWarning(void *ctx, const char *msg, ...) |
| 393 | { |
| 394 | xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; |
| 395 | xmlParserInputPtr input = NULL; |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 396 | char * str; |
Daniel Veillard | 7657576 | 2002-09-05 14:21:15 +0000 | [diff] [blame] | 397 | int len = xmlStrlen((const xmlChar *) msg); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 398 | |
Daniel Veillard | 7657576 | 2002-09-05 14:21:15 +0000 | [diff] [blame] | 399 | if ((ctxt != NULL) && (len != 0) && (msg[len - 1] != ':')) { |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 400 | input = ctxt->input; |
| 401 | if ((input->filename == NULL) && (ctxt->inputNr > 1)) |
| 402 | input = ctxt->inputTab[ctxt->inputNr - 2]; |
| 403 | |
| 404 | xmlParserPrintFileInfo(input); |
| 405 | } |
| 406 | |
| 407 | xmlGenericError(xmlGenericErrorContext, "validity warning: "); |
Daniel Veillard | 1c43dbf | 2001-06-05 17:12:52 +0000 | [diff] [blame] | 408 | XML_GET_VAR_STR(msg, str); |
Daniel Veillard | 635ef72 | 2001-10-29 11:48:19 +0000 | [diff] [blame] | 409 | xmlGenericError(xmlGenericErrorContext, "%s", str); |
Daniel Veillard | 9e7160d | 2001-03-18 23:17:47 +0000 | [diff] [blame] | 410 | if (str != NULL) |
| 411 | xmlFree(str); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 412 | |
| 413 | if (ctxt != NULL) { |
| 414 | xmlParserPrintFileContext(input); |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | |