-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
102 lines (85 loc) · 2.18 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
*
* main.c
*
*
*
*
*/
#include <stdio.h>
#include "debug.h"
#include "saxhandler.h"
void startDocument (void)
{
printf ("============startDocument============\n");
}
void endDocument (void)
{
printf ("============endDocument============\n");
}
void printValue (StrTreeNode node) {
char* value = (char*)(Closure(node));
if (value)
printf ("%s = %s\n", Key(node), value);
else
printf ("%??? = NULL...this is not a problem\n");
}
void startElement (char* uri, char* localName, char* qName, Attributes attr) {
if (uri == NULL)
uri = "NULL";
printf ("startElement uri=[%s] localName=[%s] qName=[%s]\n", uri, localName, qName);
STreeApplyNode (attr, printValue);
}
void characters (char* chars, int start, int length) {
if (chars)
printf ("characters [%s]\n", chars);
else
printf ("characters [*NULL*]\n", chars);
}
void endElement (char* uri, char* localName, char* qName) {
if (uri == NULL)
uri = "NULL";
printf ("endElement uri=[%s] localName=[%s] qName=[%s]\n", uri, localName, qName);
}
void startPrefixMapping (char* prefix, char* uri){
if (prefix == NULL)
prefix = "@@@@ BAD NULL";
if (uri == NULL)
uri = "NULL";
printf ("startPrefixMapping...prefix=%s uri=%s\n", prefix, uri);
}
void endPrefixMapping (char* prefix) {
if (prefix == NULL)
prefix = "@@@@ BAD NULL";
printf ("endPrefixMapping...prefix=%s\n", prefix);
}
void procInst (char* t, char* d)
{
printf ("processingInstruction [%s] [%s]\n", t, d);
}
void fatalerror (char* msg)
{
printf ("Fatal error: %s\n", msg);
}
void error (char* msg)
{
printf ("Error: %s\n", msg);
}
void warning (char* msg)
{
printf ("Warning: %s\n", msg);
}
void main (int ac, char* av[]) {
sax_startDocument = startDocument;
sax_endDocument = endDocument;
sax_startElement = startElement;
sax_endElement = endElement;
sax_characters = characters;
sax_startPrefixMapping = startPrefixMapping;
sax_endPrefixMapping = endPrefixMapping;
sax_processingInstruction = procInst;
sax_fatalError = fatalerror;
sax_error = error;
sax_warning = warning;
parse_xml (av[1]);
}