/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/asmxml.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 <stdlib.h>
 
2
#include <unistd.h>
 
3
#include <sys/types.h>
 
4
#include <sys/time.h>
 
5
#include <stdio.h>
 
6
#include <string.h>
 
7
#include <sys/stat.h>
 
8
#include "asm-xml.h"
 
9
 
 
10
#include "tools.h"
 
11
 
 
12
#define chunkSize 16777216
 
13
 
 
14
AXClassContext  classContext;
 
15
AXElementClass* docClass;
 
16
 
 
17
void initXML(struct TestData *td) {
 
18
    struct stat st;
 
19
    char *schema;
 
20
    
 
21
    if (!strcmp(td->fn, "xmlgen")) {
 
22
        schema = ReadFile("../xml.files/generated.schema");
 
23
        if (!schema) {
 
24
            printf("Schema file is not found\n");
 
25
            exit(1);
 
26
        }
 
27
        
 
28
    }
 
29
    
 
30
    ax_initialize((void*)malloc, (void*)free);
 
31
 
 
32
    int res = ax_initializeClassParser(&classContext);
 
33
    if (res) {
 
34
        printf("Initialization failed: %i\n", res);
 
35
        exit(1);
 
36
    }
 
37
    
 
38
    docClass = ax_classFromString(schema+sizeof(unsigned long), &classContext);
 
39
    if( docClass == NULL ) {
 
40
        printf("Schema parse is failed\n");
 
41
        exit(1);
 
42
    }
 
43
 
 
44
    free(schema);
 
45
 
 
46
}
 
47
 
 
48
 
 
49
 
 
50
void releaseXML(struct TestData *td) {
 
51
    ax_releaseClassParser(&classContext);
 
52
}
 
53
 
 
54
 
 
55
void parseXML(struct TestData *td, unsigned long iter) {
 
56
    AXParseContext parseContext;
 
57
    AXElement *root;
 
58
    
 
59
    int res = ax_initializeParser(&parseContext, chunkSize);
 
60
    if( res != 0 ) {
 
61
        printf("Parser initialization is failed\n");
 
62
        exit(1);
 
63
    }
 
64
 
 
65
    root = ax_parse(&parseContext, td->xml, docClass, 1);
 
66
    if( root == NULL ) {
 
67
        printf("Parsing is failed\n");
 
68
        exit(1);
 
69
    }
 
70
    
 
71
    ax_releaseParser(&parseContext);
 
72
}
 
73
 
 
74
int main(int argc, char *argv[]) {
 
75
    return Test(argc,argv);
 
76
}