4
#include <xercesc/util/PlatformUtils.hpp>
5
#include <xercesc/util/XMLString.hpp>
6
#include <xercesc/framework/MemBufFormatTarget.hpp>
7
#include <xercesc/util/XMLString.hpp>
8
#include <xercesc/dom/DOM.hpp>
11
#include "transcode.h"
14
char nsxsi[64]="http://www.w3.org/2001/XMLSchema-instance";
15
char nsenc[64]="http://www.w3.org/2001/12/soap-encoding";
16
char nssoap[64]="http://www.w3.org/2001/12/soap-envelope";
17
char nsopc[64]="http://opcfoundation.org/webservices/OPCDA/";
19
DOMImplementation *dom;
20
DOMLSSerializer *writer;
24
void initXML(struct TestData *td) {
25
XMLPlatformUtils::Initialize();
26
dom = DOMImplementationRegistry::getDOMImplementation(X("Core"));
28
xft = new MemBufFormatTarget();
30
writer = ((DOMImplementationLS*)dom)->createLSSerializer();
31
output = ((DOMImplementationLS*)dom)->createLSOutput();
32
output->setByteStream(xft);
35
void releaseXML(struct TestData *td) {
39
XMLPlatformUtils::Terminate();
42
void parseXML(struct TestData *td, unsigned long iter) {
43
const char id[5]="ID1\0";
44
DOMElement *pnode,*node,*node1,*node2;
50
doc = dom->createDocument(X(nssoap),X("Envelope"),NULL);
51
pnode = doc->getDocumentElement();
52
pnode->setAttribute(X("xmlns"),X(nssoap));
53
pnode->setAttribute(X("xmlns:xsi"),X(nsxsi));
54
pnode->setAttribute(X("xmlns:enc"),X(nsenc));
55
node=doc->createElementNS(X(nssoap),X("Body"));
56
pnode->appendChild(node); pnode=node;
58
node=doc->createElementNS(X(nsopc),X("WriteResponse"));
59
pnode->appendChild(node);pnode=node;
60
node=doc->createElementNS(X(nsopc),X("WriteResult"));
61
node->setAttribute(X("RcvTime"),X("2002-04-29T10:16:26.6806250+02:00"));
62
node->setAttribute(X("ReplyTime"),X("2002-04-29T10:16:26.7806250+02:00"));
63
node->setAttribute(X("ClientRequestHandle"),X("WriteError"));
64
node->setAttribute(X("RevisedLocaleID"),X("en"));
65
node->setAttribute(X("ServerState"),X("running"));
66
pnode->appendChild(node);
67
node1=doc->createElementNS(X(nsopc),X("RItemList"));
68
pnode->appendChild(node1);
69
node=doc->createElementNS(X(nsopc),X("Errors"));
70
node->setAttribute(X("ID"),X("E_UNKNOWNITEMID"));
71
pnode->appendChild(node);
72
node2=doc->createElementNS(X(nsopc),X("Text"));
73
node->appendChild(node2);
74
node2->appendChild(doc->createTextNode(X("The item does not exist in the server address space.")));
75
node=doc->createElementNS(X(nsopc),X("Errors"));
76
node->setAttribute(X("ID"),X("S_CLAMP"));
77
pnode->appendChild(node);
78
node2=doc->createElementNS(X(nsopc),X("Text"));
79
node->appendChild(node2);
80
node2->appendChild(doc->createTextNode(X("The value written was accepted but the output was clamped.")));
83
node=doc->createElementNS(X(nsopc),X("Items"));
84
node->setAttribute(X("ItemPath"),X(""));
85
node->setAttribute(X("ItemName"),X("WrongItemID1"));
86
node->setAttribute(X("Timestamp"),X("0001-01-01T00:00:00.0000000+01:00"));
87
node->setAttribute(X("ErrorID"),X("E_UNKNOWNITEMID"));
88
pnode->appendChild(node);
89
node1=doc->createElementNS(X(nsopc),X("Value"));
90
node->appendChild(node1);
91
node->setAttribute(X("xsi:nil"),X("true"));
93
node=doc->createElementNS(X(nsopc),X("Items"));
94
node->setAttribute(X("ItemPath"),X(""));
95
node->setAttribute(X("ItemName"),X("WrongItemID2"));
96
node->setAttribute(X("Timestamp"),X("0001-01-01T00:00:00.0000000+01:00"));
97
node->setAttribute(X("ErrorID"),X("E_UNKNOWNITEMID"));
98
pnode->appendChild(node);
99
node1=doc->createElementNS(X(nsopc),X("Value"));
100
node->appendChild(node1);
101
node->setAttribute(X("xsi:nil"),X("true"));
103
node=doc->createElementNS(X(nsopc),X("Items"));
104
node->setAttribute(X("ItemPath"),X("/Reals"));
105
node->setAttribute(X("ItemName"),X("Float1"));
106
node->setAttribute(X("ValueType"),X("xsd:float"));
107
node->setAttribute(X("Timestamp"),X("2002-04-29T11:47:18.1493750+02:00"));
108
pnode->appendChild(node);
109
node1=doc->createElementNS(X(nsopc),X("Value"));
110
node->appendChild(node1);
111
node->setAttribute(X("xsi:type"),X("xsd:float"));
112
node1->appendChild(doc->createTextNode(X("10.0141414")));
114
node=doc->createElementNS(X(nsopc),X("Items"));
115
node->setAttribute(X("ItemPath"),X("/Reals"));
116
node->setAttribute(X("ItemName"),X("Float2"));
117
node->setAttribute(X("ValueType"),X("xsd:float"));
118
node->setAttribute(X("Timestamp"),X("2002-04-29T11:47:18.1493750+02:00"));
119
node->setAttribute(X("SuccessID"),X("S_CLAMP"));
120
pnode->appendChild(node);
121
node1=doc->createElementNS(X(nsopc),X("Value"));
122
node->appendChild(node1);
123
node->setAttribute(X("xsi:type"),X("xsd:float"));
124
node1->appendChild(doc->createTextNode(X("1.07")));
126
for (i=0;i<td->inc;i++) {
127
node=doc->createElementNS(X(nsopc),X("Items"));
128
node->setAttribute(X("ItemPath"),X("/Integer"));
129
node->setAttribute(X("ItemName"),X("IntN"));
130
node->setAttribute(X("ValueType"),X("xsd:int"));
131
node->setAttribute(X("Timestamp"),X("2002-04-29T11:47:18.1493750+02:00"));
132
node->setAttribute(X("SuccessID"),X("S_CLAMP"));
133
pnode->appendChild(node);
134
node1=doc->createElementNS(X(nsopc),X("Value"));
135
node->appendChild(node1);
136
node->setAttribute(X("xsi:type"),X("xsd:int"));
137
sprintf(str,"%u",rand());
138
node1->appendChild(doc->createTextNode(X(str)));
141
writer->write(doc, output);
142
mem=(XMLByte*)((MemBufFormatTarget*)xft)->getRawBuffer();
144
// if (iter==td->iterations) puts((char*)mem);
145
((MemBufFormatTarget*)xft)->reset();
151
int main(int argc, char *argv[]) {
152
return Test(argc,argv);