/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/oracle-dom.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 <oratypes.h>
 
4
#include <oraxml.h>
 
5
 
 
6
#include "tools.h"
 
7
#define memsize MAXOUTSIZE
 
8
 
 
9
/* 
 
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
 
13
    this memory.
 
14
    But: setAttribute(nodeVar,"name","value"); - works OK, it copies
 
15
    context of stack variable.
 
16
*/
 
17
 
 
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/";
 
22
 
 
23
xmlctx          *ctx;
 
24
xmldomimp       *dom;
 
25
char            *mem;
 
26
 
 
27
void initXML(struct TestData *td) {
 
28
    unsigned int ecode;
 
29
    ctx = xmlinit(&ecode, 0, 0, 0, 0, 0, 0, 0, 0);
 
30
    if (!ctx)
 
31
    {
 
32
        printf("Failed to initialze XML parser, error %u\n", (unsigned) ecode);
 
33
        exit(1);
 
34
    }
 
35
    dom = getImplementation(ctx);
 
36
    mem = malloc(memsize);
 
37
}
 
38
 
 
39
void releaseXML(struct TestData *td) {
 
40
    free(mem);
 
41
    xmlterm(ctx);
 
42
}
 
43
 
 
44
void parseXML(struct TestData *td, unsigned long iter) {
 
45
    unsigned int ecode;
 
46
    xmlnode *doc;
 
47
    xmlnode *pnode,*node,*node1,*node2;
 
48
    char str[td->inc][16];
 
49
    int i;
 
50
    
 
51
    
 
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."));
 
83
 
 
84
    pnode=node1;
 
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");
 
94
 
 
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");
 
104
 
 
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"));
 
115
 
 
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"));
 
127
 
 
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]));
 
141
    }
 
142
 
 
143
    printBuffer(mem,memsize,doc,0,0);
 
144
    
 
145
//    if (iter==td->iterations) puts(mem);
 
146
 
 
147
//      xmlclean(ctx);
 
148
    xmlterm(ctx);
 
149
    ctx = xmlinit(&ecode, 0, 0, 0, 0, 0, 0, 0, 0);
 
150
}
 
151
 
 
152
 
 
153
int main(int argc, char *argv[]) {
 
154
    return Test(argc,argv);
 
155
}