/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/qt-dom.cpp

  • 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 <qxml.h>
 
4
#include <qwindowdefs.h>
 
5
#include <qstring.h>
 
6
#include <qdom.h>
 
7
 
 
8
#include "tools.h"
 
9
 
 
10
 
 
11
QString prefix="<?xml version=\"1.0\"?>";
 
12
 
 
13
QString nsxsi="http://www.w3.org/2001/XMLSchema-instance";
 
14
QString nsenc="http://www.w3.org/2001/12/soap-encoding";
 
15
QString nssoap="http://www.w3.org/2001/12/soap-envelope";
 
16
QString nsopc="http://opcfoundation.org/webservices/OPCDA/";
 
17
 
 
18
void initXML(struct TestData *td) {
 
19
}
 
20
 
 
21
void releaseXML(struct TestData *td) {
 
22
}
 
23
 
 
24
void parseXML(struct TestData *td, unsigned long iter) {
 
25
    const char id[5]="ID1\0";
 
26
    QDomDocument doc;
 
27
    QDomElement pnode,node,node1,node2;
 
28
    QString mem;
 
29
    char str[16];
 
30
    int i;
 
31
    
 
32
    pnode=doc.createElementNS(nssoap,"soap:Envelope");
 
33
    doc.appendChild(pnode);
 
34
    pnode.setAttribute("xmlns:xsi",nsxsi);
 
35
    pnode.setAttribute("xmlns:enc",nsenc);
 
36
    node=doc.createElementNS(nssoap,"Body");
 
37
    node.setPrefix("soap");
 
38
    pnode.appendChild(node);pnode=node;
 
39
 
 
40
    node=doc.createElementNS(nsopc,"WriteResponse");
 
41
    pnode.appendChild(node);pnode=node;
 
42
    node=doc.createElementNS(nsopc,"WriteResult");
 
43
    node.setAttribute("RcvTime","2002-04-29T10:16:26.6806250+02:00");
 
44
    node.setAttribute("ReplyTime","2002-04-29T10:16:26.7806250+02:00");
 
45
    node.setAttribute("ClientRequestHandle","WriteError");
 
46
    node.setAttribute("RevisedLocaleID","en");
 
47
    node.setAttribute("ServerState","running");
 
48
    pnode.appendChild(node);
 
49
    node1=doc.createElementNS(nsopc,"RItemList");
 
50
    pnode.appendChild(node1);
 
51
    node=doc.createElementNS(nsopc,"Errors");
 
52
    node.setAttribute("ID","E_UNKNOWNITEMID");
 
53
    pnode.appendChild(node);
 
54
    node2=doc.createElementNS(nsopc,"Text");
 
55
    node.appendChild(node2);    
 
56
    node2.appendChild(doc.createTextNode("The item does not exist in the server address space."));
 
57
    node=doc.createElementNS(nsopc,"Errors");
 
58
    node.setAttribute("ID","S_CLAMP");
 
59
    pnode.appendChild(node);
 
60
    node2=doc.createElementNS(nsopc,"Text");
 
61
    node.appendChild(node2);    
 
62
    node2.appendChild(doc.createTextNode("The value written was accepted but the output was clamped."));
 
63
 
 
64
    pnode=node1;
 
65
    node=doc.createElementNS(nsopc,"Items");
 
66
    node.setAttribute("ItemPath","");
 
67
    node.setAttribute("ItemName","WrongItemID1");
 
68
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
69
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
 
70
    pnode.appendChild(node);
 
71
    node1=doc.createElementNS(nsopc,"Value");
 
72
    node.appendChild(node1);
 
73
    node.setAttribute("xsi:nil","true");
 
74
 
 
75
    node=doc.createElementNS(nsopc,"Items");
 
76
    node.setAttribute("ItemPath","");
 
77
    node.setAttribute("ItemName","WrongItemID2");
 
78
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
79
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
 
80
    pnode.appendChild(node);
 
81
    node1=doc.createElementNS(nsopc,"Value");
 
82
    node.appendChild(node1);
 
83
    node.setAttribute("xsi:nil","true");
 
84
 
 
85
    node=doc.createElementNS(nsopc,"Items");
 
86
    node.setAttribute("ItemPath","/Reals");
 
87
    node.setAttribute("ItemName","Float1");
 
88
    node.setAttribute("ValueType","xsd:float");
 
89
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
90
    pnode.appendChild(node);
 
91
    node1=doc.createElementNS(nsopc,"Value");
 
92
    node.appendChild(node1);
 
93
    node.setAttribute("xsi:type","xsd:float");
 
94
    node1.appendChild(doc.createTextNode("10.0141414"));
 
95
 
 
96
    node=doc.createElementNS(nsopc,"Items");
 
97
    node.setAttribute("ItemPath","/Reals");
 
98
    node.setAttribute("ItemName","Float2");
 
99
    node.setAttribute("ValueType","xsd:float");
 
100
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
101
    node.setAttribute("SuccessID","S_CLAMP");
 
102
    pnode.appendChild(node);
 
103
    node1=doc.createElementNS(nsopc,"Value");
 
104
    node.appendChild(node1);
 
105
    node.setAttribute("xsi:type","xsd:float");
 
106
    node1.appendChild(doc.createTextNode("1.07"));
 
107
    
 
108
    for (i=0;i<td->inc;i++) {
 
109
        node=doc.createElementNS(nsopc,"Items");
 
110
        node.setAttribute("ItemPath","/Integer");
 
111
        node.setAttribute("ItemName","IntN");
 
112
        node.setAttribute("ValueType","xsd:int");
 
113
        node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
114
        node.setAttribute("SuccessID","S_CLAMP");
 
115
        pnode.appendChild(node);
 
116
        node1=doc.createElementNS(nsopc,"Value");
 
117
        node.appendChild(node1);
 
118
        node.setAttribute("xsi:type","xsd:int");
 
119
        sprintf(str,"%u",rand());
 
120
        node1.appendChild(doc.createTextNode(str));
 
121
    }
 
122
 
 
123
    mem=doc.toString();
 
124
    
 
125
//    if (iter==td->iterations) cout<<prefix<<mem;
 
126
 
 
127
}
 
128
 
 
129
 
 
130
 
 
131
int main(int argc, char *argv[]) {
 
132
    return Test(argc,argv);
 
133
}