source: trunk/src/xml_error.c @ 120

Last change on this file since 120 was 120, checked in by cameron, 11 years ago

Error reporting for character validation errors.

File size: 1.8 KB
Line 
1/*  xml_error.c - Error reporting for XML parsing/validation.
2    Copyright (c) 2008, Robert D. Cameron and Dan Lin.
3    Licensed to the public under the Open Software License 3.0.
4    Licensed to International Characters, Inc., under the Academic
5    Free License 3.0.
6*/
7
8#include "xml_error.h"
9
10void ShowConstraintError(XML_Constraint errCode) {
11        if (errCode < vErr_vc_roottype) {
12                fprintf(stderr, "Violation of well-formedness constraint: %s\n", XML_Constraint_Strings[errCode]);
13        }
14        else fprintf(stderr, "Violation of validity constraint: %s\n", XML_Constraint_Strings[errCode]);
15}
16
17void ShowSyntaxError(XML_NonTerminal errCode) {
18        fprintf(stderr, "Syntax error in production: %s\n", XML_NonTerminal_Names[errCode]);
19}
20
21
22void NoEncodingError(char * msg) {
23        fprintf(stderr, "Error : %s\n", msg);
24        exit(-1);
25}
26
27void EncodingError(char * msg, unsigned char * encoding, int lgth) {
28        fprintf(stderr, "Error : Illegal/unsupported %s encoding of length %i: \"", msg, lgth);
29        for (int i = 0; i < lgth; i++) printf("%c", encoding[i]);
30        printf("\"\n"); 
31        exit(-1);
32}
33
34void CharSetValidationError(char * encoding, int err_pos) {
35        fprintf(stderr, "Error: Invalid %s character in input stream at position %i\n", encoding, err_pos);
36        exit(-1);
37}
38
39void XMLCharacterError(int err_pos) {
40        fprintf(stderr, "Illegal control character in XML input stream at position %i\n", err_pos);
41        exit(-1);
42}
43
44void IncompleteCodeUnitError() {
45        fprintf(stderr, "Error: Incomplete code unit at end of file.\n");
46        exit(-1);
47}
48
49void DeclarationError(int pos) {
50        fprintf(stderr, "Parsing error at position %i in XML or Text declaration.\n", pos);
51        exit(-1);
52}
53
54void ImplementationLimitError(char * msg) {
55        fprintf(stderr, "Fatal implementation limit - %s\n", msg);
56        exit(-1);
57}
58
59void ContentModelError() {
60        fprintf(stderr, "Error: nondeterminism in content model.\n");
61        exit(-1);
62}
63
Note: See TracBrowser for help on using the repository browser.