/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/libxml.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 <libxml/xmlmemory.h>
 
4
#include <libxml/parser.h>
 
5
 
 
6
#if LIBXML_VERSION > 20600
 
7
#define READ_MEMORY
 
8
//xmlParserCtxtPtr ctxt = NULL;
 
9
#endif
 
10
 
 
11
#ifdef READ_MEMORY
 
12
#define DTD_VALIDATION_SUPPORTED
 
13
#endif
 
14
 
 
15
#include "tools.h"
 
16
 
 
17
 
 
18
 
 
19
void initXML(struct TestData *td) {
 
20
    xmlInitParser();
 
21
#ifdef READ_MEMORY
 
22
/*    ctxt = xmlNewParserCtxt();
 
23
    if (!ctxt) {
 
24
        fprintf(stderr, "Can't create parser context!\n");
 
25
        exit(0);
 
26
    }*/
 
27
#endif
 
28
}
 
29
 
 
30
void releaseXML(struct TestData *td) {
 
31
#ifdef READ_MEMORY
 
32
//    if (ctxt) xmlFreeParserCtxt(ctxt);
 
33
#endif
 
34
    xmlCleanupParser();
 
35
}
 
36
 
 
37
void parseXML(struct TestData *td, unsigned long iter) {
 
38
    int err;
 
39
    xmlDocPtr doc;
 
40
#ifdef READ_MEMORY
 
41
#ifdef DTD_VALIDATION
 
42
    doc=xmlReadMemory(td->xml,td->xmllen,"xml",NULL,XML_PARSE_DTDVALID);
 
43
#else
 
44
    doc=xmlReadMemory(td->xml,td->xmllen,"xml",NULL,0);
 
45
#endif
 
46
/*    doc=xmlCtxtReadMemory(ctxt,td->xml,td->xmllen,"xml",NULL,XML_PARSE_DTDVALID);
 
47
    printf("%u\n",ctxt->valid); */
 
48
 
 
49
 
 
50
#else
 
51
    doc=xmlParseMemory(td->xml,td->xmllen);
 
52
#endif
 
53
    if (!doc) {
 
54
        printf("Error parsing document!\n");
 
55
        exit(0);
 
56
    }
 
57
    xmlFreeDoc(doc);    
 
58
 
 
59
}
 
60
 
 
61
int main(int argc, char *argv[]) {
 
62
    return Test(argc,argv);
 
63
}