7
#define memsize MAXOUTSIZE
10
Very strange optimization of library function: setAttribute(node,name,value)
11
setAttribute(nodeVar,"name",valueVar); - doesn't copy context of
12
valueVar but simply make a pointer on it. xmlterm() wouldn't free
14
But: setAttribute(nodeVar,"name","value"); - works OK, it copies
15
context of stack variable.
18
char nsxsi[64]="http://www.w3.org/2001/XMLSchema-instance";
19
char nsenc[64]="http://www.w3.org/2001/12/soap-encoding";
20
char nssoap[64]="http://www.w3.org/2001/12/soap-envelope";
21
char nsopc[64]="http://opcfoundation.org/webservices/OPCDA/";
27
void initXML(struct TestData *td) {
29
ctx = xmlinit(&ecode, 0, 0, 0, 0, 0, 0, 0, 0);
32
printf("Failed to initialze XML parser, error %u\n", (unsigned) ecode);
35
dom = getImplementation(ctx);
36
mem = malloc(memsize);
39
void releaseXML(struct TestData *td) {
44
void parseXML(struct TestData *td, unsigned long iter) {
47
xmlnode *pnode,*node,*node1,*node2;
48
char str[td->inc][16];
52
doc=createDocument(ctx);
53
pnode=createElementNS(ctx,nssoap,"soap:Envelope");
54
appendChild(ctx,doc,pnode);
55
setAttribute(ctx,pnode,"xmlns:soap",nssoap);
56
setAttribute(ctx,pnode,"xmlns:xsi",nsxsi);
57
setAttribute(ctx,pnode,"xmlns:enc",nsenc);
58
node=createElementNS(ctx,nssoap,"soap:Body");
59
appendChild(ctx,pnode,node);pnode=node;
60
node=createElementNS(ctx,nsopc,"WriteResponse");
61
appendChild(ctx,pnode,node);pnode=node;
62
node=createElementNS(ctx,nsopc,"WriteResult");
63
setAttribute(ctx,node,"RcvTime","2002-04-29T10:16:26.6806250+02:00");
64
setAttribute(ctx,node,"ReplyTime","2002-04-29T10:16:26.7806250+02:00");
65
setAttribute(ctx,node,"ClientRequestHandle","WriteError");
66
setAttribute(ctx,node,"RevisedLocaleID","en");
67
setAttribute(ctx,node,"ServerState","running");
68
appendChild(ctx,pnode,node);
69
node1=createElementNS(ctx,nssoap,"RItemList");
70
appendChild(ctx,pnode,node1);
71
node=createElementNS(ctx,nssoap,"Errors");
72
setAttribute(ctx,node,"ID","E_UNKNOWNITEMID");
73
appendChild(ctx,pnode,node);
74
node2=createElementNS(ctx,nssoap,"Text");
75
appendChild(ctx,node,node2);
76
appendChild(ctx,node2,createTextNode(ctx,"The item does not exist in the server address space."));
77
node=createElementNS(ctx,nssoap,"Errors");
78
setAttribute(ctx,node,"ID","S_CLAMP");
79
appendChild(ctx,pnode,node);
80
node2=createElementNS(ctx,nssoap,"Text");
81
appendChild(ctx,node,node2);
82
appendChild(ctx,node2,createTextNode(ctx,"The value written was accepted but the output was clamped."));
85
node=createElementNS(ctx,nssoap,"Items");
86
setAttribute(ctx,node,"ItemPath","");
87
setAttribute(ctx,node,"ItemName","WrongItemID1");
88
setAttribute(ctx,node,"Timestamp","0001-01-01T00:00:00.0000000+01:00");
89
setAttribute(ctx,node,"ErrorID","E_UNKNOWNITEMID");
90
appendChild(ctx,pnode,node);
91
node1=createElementNS(ctx,nssoap,"Value");
92
appendChild(ctx,node,node1);
93
setAttribute(ctx,node1,"xsi:nil","true");
95
node=createElementNS(ctx,nssoap,"Items");
96
setAttribute(ctx,node,"ItemPath","");
97
setAttribute(ctx,node,"ItemName","WrongItemID2");
98
setAttribute(ctx,node,"Timestamp","0001-01-01T00:00:00.0000000+01:00");
99
setAttribute(ctx,node,"ErrorID","E_UNKNOWNITEMID");
100
appendChild(ctx,pnode,node);
101
node1=createElementNS(ctx,nssoap,"Value");
102
appendChild(ctx,node,node1);
103
setAttribute(ctx,node1,"xsi:nil","true");
105
node=createElementNS(ctx,nssoap,"Items");
106
setAttribute(ctx,node,"ItemPath","/Reals");
107
setAttribute(ctx,node,"ItemName","Float1");
108
setAttribute(ctx,node,"ValueType","xsd:float");
109
setAttribute(ctx,node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
110
appendChild(ctx,pnode,node);
111
node1=createElementNS(ctx,nssoap,"Value");
112
appendChild(ctx,node,node1);
113
setAttribute(ctx,node1,"xsi:type","xsd:float");
114
appendChild(ctx,node1,createTextNode(ctx,"10.0141414"));
116
node=createElementNS(ctx,nssoap,"Items");
117
setAttribute(ctx,node,"ItemPath","/Reals");
118
setAttribute(ctx,node,"ItemName","Float2");
119
setAttribute(ctx,node,"ValueType","xsd:float");
120
setAttribute(ctx,node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
121
setAttribute(ctx,node,"SuccessID","S_CLAMP");
122
appendChild(ctx,pnode,node);
123
node1=createElementNS(ctx,nssoap,"Value");
124
appendChild(ctx,node,node1);
125
setAttribute(ctx,node1,"xsi:type","xsd:float");
126
appendChild(ctx,node1,createTextNode(ctx,"1.07"));
128
for (i=0;i<td->inc;i++) {
129
node=createElementNS(ctx,nssoap,"Items");
130
setAttribute(ctx,node,"ItemPath","/Integer");
131
setAttribute(ctx,node,"ItemName","IntN");
132
setAttribute(ctx,node,"ValueType","xsd:int");
133
setAttribute(ctx,node,"Timestamp","2002-04-29T11:47:18.1493750+02:00");
134
setAttribute(ctx,node,"SuccessID","S_CLAMP");
135
appendChild(ctx,pnode,node);
136
node1=createElementNS(ctx,nssoap,"Value");
137
appendChild(ctx,node,node1);
138
setAttribute(ctx,node1,"xsi:type","xsd:int");
139
sprintf(str[i],"%u",rand());
140
appendChild(ctx,node1,createTextNode(ctx,str[i]));
143
printBuffer(mem,memsize,doc,0,0);
145
// if (iter==td->iterations) puts(mem);
149
ctx = xmlinit(&ecode, 0, 0, 0, 0, 0, 0, 0, 0);
153
int main(int argc, char *argv[]) {
154
return Test(argc,argv);