source: trunk/src/xml_error.c @ 124

Last change on this file since 124 was 124, checked in by lindanl, 11 years ago

Name checking and other well-formedness checking.

File size: 1.9 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                exit(-1);
14        }
15        else {
16#ifdef VALIDATION
17                fprintf(stderr, "Violation of validity constraint: %s\n", XML_Constraint_Strings[errCode]);
18                exit(-1);
19#endif
20        }
21}
22
23void ShowSyntaxError(XML_NonTerminal errCode) {
24        fprintf(stderr, "Syntax error in production: %s\n", XML_NonTerminal_Names[errCode]);
25}
26
27
28void NoEncodingError(char * msg) {
29        fprintf(stderr, "Error : %s\n", msg);
30        exit(-1);
31}
32
33void EncodingError(char * msg, unsigned char * encoding, int lgth) {
34        fprintf(stderr, "Error : Illegal/unsupported %s encoding of length %i: \"", msg, lgth);
35        for (int i = 0; i < lgth; i++) fprintf(stderr, "%c", encoding[i]);
36        fprintf(stderr, "\"\n"); 
37        exit(-1);
38}
39
40void CharSetValidationError(char * encoding, int err_pos) {
41        fprintf(stderr, "Error: Invalid %s character in input stream at position %i\n", encoding, err_pos);
42        exit(-1);
43}
44
45void XMLCharacterError(int err_pos) {
46        fprintf(stderr, "Illegal control character in XML input stream at position %i\n", err_pos);
47        exit(-1);
48}
49
50void IncompleteCodeUnitError() {
51        fprintf(stderr, "Error: Incomplete code unit at end of file.\n");
52        exit(-1);
53}
54
55void DeclarationError(int pos) {
56        fprintf(stderr, "Parsing error at position %i in XML or Text declaration.\n", pos);
57        exit(-1);
58}
59
60void ImplementationLimitError(char * msg) {
61        fprintf(stderr, "Fatal implementation limit - %s\n", msg);
62        exit(-1);
63}
64
65void ContentModelError() {
66        fprintf(stderr, "Error: nondeterminism in content model.\n");
67        exit(-1);
68}
69
Note: See TracBrowser for help on using the repository browser.