/xmlbench/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/xmlbench/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.String;
import oracle.xml.parser.v2.XMLDocument;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

public class oracle_dom2 extends bench {
    String nsxsi="http://www.w3.org/2001/XMLSchema-instance";
    String nsenc="http://www.w3.org/2001/12/soap-encoding";
    String nssoap="http://www.w3.org/2001/12/soap-envelope";
    String nsopc="http://opcfoundation.org/webservices/OPCDA/";
    Random generator;

    public void InitXML(int enlarge) {
	if (enlarge>0) generator = new Random();
    }

    public void ParseXML(int enlarge, int iters, int iter) {
	XMLDocument doc;
	Element proot,pnode,node,node1,node2;
	ByteArrayOutputStream mem = new ByteArrayOutputStream();
	int i;
	
	try {
	    doc = new XMLDocument();
	    proot = doc.createElementNS(nssoap,"Envelope");
	    proot.setAttribute("xmlns",nssoap);
	    proot.setAttribute("xmlns:xsi",nsxsi);
	    proot.setAttribute("xmlns:enc",nsenc);
	    doc.appendChild(proot);
	    pnode = doc.createElementNS(nssoap,"Body");
	    proot.appendChild(pnode);

    node=doc.createElementNS(nsopc,"WriteResponse");
    pnode.appendChild(node);pnode=node;
    node=doc.createElementNS(nsopc,"WriteResult");
    node.setAttribute("RcvTime","2002-04-29T10:16:26.6806250+02:00");
    node.setAttribute("ReplyTime","2002-04-29T10:16:26.7806250+02:00");
    node.setAttribute("ClientRequestHandle","WriteError");
    node.setAttribute("RevisedLocaleID","en");
    node.setAttribute("ServerState","running");
    pnode.appendChild(node);
    node1=doc.createElementNS(nsopc,"RItemList");
    pnode.appendChild(node1);
    node=doc.createElementNS(nsopc,"Errors");
    node.setAttribute("ID","E_UNKNOWNITEMID");
    pnode.appendChild(node);
    node2=doc.createElementNS(nsopc,"Text");
    node.appendChild(node2);    
    node2.appendChild(doc.createTextNode("The item does not exist in the server address space."));
    node=doc.createElementNS(nsopc,"Errors");
    node.setAttribute("ID","S_CLAMP");
    pnode.appendChild(node);
    node2=doc.createElementNS(nsopc,"Text");
    node.appendChild(node2);    
    node2.appendChild(doc.createTextNode("The value written was accepted but the output was clamped."));

    pnode=node1;
    node=doc.createElementNS(nsopc,"Items");
    node.setAttribute("ItemPath","");
    node.setAttribute("ItemName","WrongItemID1");
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
    pnode.appendChild(node);
    node1=doc.createElementNS(nsopc,"Value");
    node.appendChild(node1);
    node.setAttribute("xsi:nil","true");

    node=doc.createElementNS(nsopc,"Items");
    node.setAttribute("ItemPath","");
    node.setAttribute("ItemName","WrongItemID2");
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
    pnode.appendChild(node);
    node1=doc.createElementNS(nsopc,"Value");
    node.appendChild(node1);
    node.setAttribute("xsi:nil","true");

    node=doc.createElementNS(nsopc,"Items");
    node.setAttribute("ItemPath","/Reals");
    node.setAttribute("ItemName","Float1");
    node.setAttribute("ValueType","xsd:float");
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
    pnode.appendChild(node);
    node1=doc.createElementNS(nsopc,"Value");
    node.appendChild(node1);
    node.setAttribute("xsi:type","xsd:float");
    node1.appendChild(doc.createTextNode("10.0141414"));

    node=doc.createElementNS(nsopc,"Items");
    node.setAttribute("ItemPath","/Reals");
    node.setAttribute("ItemName","Float2");
    node.setAttribute("ValueType","xsd:float");
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
    node.setAttribute("SuccessID","S_CLAMP");
    pnode.appendChild(node);
    node1=doc.createElementNS(nsopc,"Value");
    node.appendChild(node1);
    node.setAttribute("xsi:type","xsd:float");
    node1.appendChild(doc.createTextNode("1.07"));
    
    for (i=0;i<enlarge;i++) {
        node=doc.createElementNS(nsopc,"Items");
	node.setAttribute("ItemPath","/Integer");
        node.setAttribute("ItemName","IntN");
	node.setAttribute("ValueType","xsd:int");
        node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
        node.setAttribute("SuccessID","S_CLAMP");
	pnode.appendChild(node);
        node1=doc.createElementNS(nsopc,"Value");
	node.appendChild(node1);
	node.setAttribute("xsi:type","xsd:int");
        node1.appendChild(doc.createTextNode(Integer.toString(generator.nextInt())));
    }
	    doc.print(mem);
	}
	catch (Exception e)
        {
    	    System.out.println(e.toString());
        }

//	if (iter==iters) System.out.println(mem);
    }

    static public void main(String argv[]) throws IOException {
	bench mybench = new oracle_dom2();
	mybench.Bench(argv);
    }
    
}