/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk
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
#include <stdio.h>
#include <sys/time.h>
#include <libxml/xmlreader.h>

#include "tools.h"

//xmlSAXHandler handler;

void initXML(struct TestData *td) {
    xmlInitParser();
//    initxmlDefaultSAXHandler(&handler,0);
}

void releaseXML(struct TestData *td) {
    xmlCleanupParser();
}

void parseXML(struct TestData *td, unsigned long iter) {
    int res;
    xmlTextReaderPtr ctx;

#ifdef DTD_VALIDATION
    ctx = xmlReaderForMemory(td->xml, td->xmllen, "xml", NULL, XML_PARSE_DTDVALID);
#else
    ctx = xmlReaderForMemory(td->xml, td->xmllen, "xml", NULL, 0);
#endif

    if (!ctx) {
	printf("Parsing is failed\n");
	exit(1);
    }
    res = xmlTextReaderRead(ctx);
    while (res == 1) {
	//printf("%u\n", xmlTextReaderNodeType(ctx));
	if (xmlTextReaderNodeType(ctx) == XML_READER_TYPE_ELEMENT) {
	    //xmlTextReaderMoveToFirstAttribute(ctx);
	    while (xmlTextReaderMoveToNextAttribute(ctx));
	    xmlTextReaderMoveToElement(ctx);
	}
	res = xmlTextReaderRead(ctx);
    }
    xmlFreeTextReader(ctx);

    if (res) {
	printf("Parsing is failed with code: %i\n", res);
	exit(1);
    }
}

int main(int argc, char *argv[]) {
    return Test(argc,argv);
}