/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 create/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
#include "tools.h"
 
7
 
 
8
void initXML(struct TestData *td) {
 
9
    xmlInitParser();
 
10
}
 
11
 
 
12
void releaseXML(struct TestData *td) {
 
13
        xmlCleanupParser();
 
14
}
 
15
 
 
16
void parseXML(struct TestData *td, unsigned long iter) {
 
17
    xmlDocPtr doc;
 
18
    xmlNodePtr pnode,node,node1;
 
19
    xmlNsPtr ns1,ns2;
 
20
    xmlChar *mem;
 
21
    int memsize;
 
22
    char s[16];
 
23
    int i;
 
24
    
 
25
    doc = xmlNewDoc("1.0");
 
26
    pnode = xmlNewChild((xmlNodePtr)doc,NULL,"Envelope",NULL);
 
27
    xmlNewNs(pnode,"http://www.w3.org/2001/12/soap-envelope",NULL);
 
28
    ns1=xmlNewNs(pnode,"http://www.w3.org/2001/XMLSchema-instance","xsi");
 
29
    ns2=xmlNewNs(pnode,"http://www.w3.org/2001/12/soap-encoding","enc");
 
30
    pnode=xmlNewChild(pnode,NULL,"Body",NULL);
 
31
    pnode=xmlNewChild(pnode,NULL,"WriteResponse",NULL);
 
32
    xmlNewNs(pnode,"http://opcfoundation.org/webservices/OPCDA/",NULL);
 
33
    node=xmlNewChild(pnode,NULL,"WriteResult",NULL);
 
34
    xmlSetProp(node,"RcvTime","2002-04-29T10:16:26.6806250+02:00");
 
35
    xmlSetProp(node,"ReplyTime","2002-04-29T10:16:26.7806250+02:00");
 
36
    xmlSetProp(node,"ClientRequestHandle","WriteError");
 
37
    xmlSetProp(node,"RevisedLocaleID","en");
 
38
    xmlSetProp(node,"ServerState","running");
 
39
    node1=xmlNewChild(pnode,NULL,"RItemList",NULL);
 
40
    node=xmlNewChild(pnode,NULL,"Errors",NULL);
 
41
    xmlSetProp(node,"ID","E_UNKNOWNITEMID");
 
42
    xmlNewChild(node,NULL,"Text","The item does not exist in the server address space.");
 
43
    node=xmlNewChild(pnode,NULL,"Errors",NULL);
 
44
    xmlSetProp(node,"ID","S_CLAMP");
 
45
    xmlNewChild(node,NULL,"Text","The value written was accepted but the output was clamped.");
 
46
 
 
47
    pnode=node1;
 
48
    node=xmlNewChild(pnode,NULL,"Items",NULL);
 
49
    xmlSetProp(node,"ItemPath","");
 
50
    xmlSetProp(node,"ItemName","WrongItemID1");
 
51
    xmlSetProp(node,"Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
52
    xmlSetProp(node,"ErrorID","E_UNKNOWNITEMID");
 
53
    node1=xmlNewChild(node,NULL,"Value",NULL);
 
54
    xmlSetProp(node1,"xsi:nil","true");
 
55
 
 
56
    node=xmlNewChild(pnode,NULL,"Items",NULL);
 
57
    xmlSetProp(node,"ItemPath","");
 
58
    xmlSetProp(node,"ItemName","WrongItemID2");
 
59
    xmlSetProp(node,"Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
60
    xmlSetProp(node,"ErrorID","E_UNKNOWNITEMID");
 
61
    node1=xmlNewChild(node,NULL,"Value",NULL);
 
62
    xmlSetProp(node1,"xsi:nil","true");
 
63
 
 
64
    node=xmlNewChild(pnode,NULL,"Items",NULL);
 
65
    xmlSetProp(node,"ItemPath","/Reals");
 
66
    xmlSetProp(node,"ItemName","Float1");
 
67
    xmlSetProp(node,"ValueType","xsd:float");
 
68
    xmlSetProp(node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
69
    node1=xmlNewChild(node,NULL,"Value","10.0141414");
 
70
    xmlSetNsProp(node1,ns1,"type","xsd:float");
 
71
 
 
72
    node=xmlNewChild(pnode,NULL,"Items",NULL);
 
73
    xmlSetProp(node,"ItemPath","/Reals");
 
74
    xmlSetProp(node,"ItemName","Float2");
 
75
    xmlSetProp(node,"ValueType","xsd:float");
 
76
    xmlSetProp(node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
77
    xmlSetProp(node,"SuccessID","S_CLAMP");
 
78
    node1=xmlNewChild(node,NULL,"Value","1.07");
 
79
    xmlSetNsProp(node1,ns1,"type","xsd:float");
 
80
 
 
81
    for (i=0;i<td->inc;i++) {
 
82
        node=xmlNewChild(pnode,NULL,"Items",NULL);
 
83
        xmlSetProp(node,"ItemPath","/Integer");
 
84
        xmlSetProp(node,"ItemName","IntN");
 
85
        xmlSetProp(node,"ValueType","xsd:int");
 
86
        xmlSetProp(node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
87
        xmlSetProp(node,"SuccessID","S_CLAMP");
 
88
        sprintf(s,"%u",rand());
 
89
        node1=xmlNewChild(node,NULL,"Value",(unsigned char*)s);
 
90
        xmlSetNsProp(node1,ns1,"type","xsd:int");
 
91
    }
 
92
 
 
93
    xmlDocDumpMemory(doc,&mem,&memsize);
 
94
    xmlFreeDoc(doc);    
 
95
 
 
96
//    if (iter==td->iterations) puts(mem);
 
97
    free(mem);
 
98
}
 
99
 
 
100
int main(int argc, char *argv[]) {
 
101
    return Test(argc,argv);
 
102
}