/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk

« back to all changes in this revision

Viewing changes to parse/oracle-sax.c

  • Committer: Suren A. Chilingaryan
  • Date: 2009-02-16 09:27:17 UTC
  • Revision ID: csa@dside.dyndns.org-20090216092717-wipyvaaw2srxhgns
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <sys/time.h>
 
3
#include <oratypes.h>
 
4
#include <oraxml.h>
 
5
 
 
6
#define DTD_VALIDATION_SUPPORTED
 
7
#include "tools.h"
 
8
 
 
9
int startDocument(void *ctx) {
 
10
    return 0;
 
11
}
 
12
int endDocument(void *ctx) {
 
13
    return 0;
 
14
}
 
15
int startElement(void *ctx, const oratext *name, const struct xmlnodes *attrs) {
 
16
    return 0;
 
17
}
 
18
int endElement(void *ctx, const oratext *name) {
 
19
    return 0;
 
20
}
 
21
int characters(void *ctx, const oratext *ch, size_t len) {
 
22
    return 0;
 
23
}
 
24
 
 
25
xmlsaxcb saxcb = {
 
26
    startDocument,
 
27
    endDocument,
 
28
    startElement,
 
29
    endElement,
 
30
    characters
 
31
};
 
32
 
 
33
xmlctx  *ctx;
 
34
 
 
35
void initXML(struct TestData *td) {
 
36
    unsigned int ecode;
 
37
    ctx = xmlinit(&ecode, 0, 0, 0, &saxcb, 0, 0, 0, 0);
 
38
    if (!ctx)
 
39
    {
 
40
        fprintf(stderr,"Failed to initialze XML parser, error %u\n", (unsigned) ecode);
 
41
        exit(1);
 
42
    }
 
43
}
 
44
 
 
45
void releaseXML(struct TestData *td) {
 
46
    xmlterm(ctx);
 
47
}
 
48
 
 
49
void parseXML(struct TestData *td, unsigned long iter) {
 
50
    unsigned int ecode;
 
51
    
 
52
#ifdef DTD_VALIDATION
 
53
    ecode=xmlparsebuf(ctx,td->xml,td->xmllen,0,XML_FLAG_DISCARD_WHITESPACE|XML_FLAG_VALIDATE);
 
54
#else
 
55
    ecode=xmlparsebuf(ctx,td->xml,td->xmllen,0,XML_FLAG_DISCARD_WHITESPACE);
 
56
#endif
 
57
    if (ecode) {
 
58
        fprintf(stderr,"Failed to parse XML file, error %u\n", (unsigned) ecode);
 
59
        exit(1);
 
60
    }   
 
61
    
 
62
//    xmlclean(ctx);
 
63
    xmlterm(ctx);
 
64
    ctx = xmlinit(&ecode, 0, 0, 0, &saxcb, 0, 0, 0, 0);
 
65
}
 
66
 
 
67
 
 
68
int main(int argc, char *argv[]) {
 
69
    return Test(argc,argv);
 
70
}