/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_dom2.java

  • 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
import java.io.*;
 
2
import java.util.*;
 
3
import java.text.*;
 
4
import java.lang.String;
 
5
import oracle.xml.parser.v2.XMLDocument;
 
6
import org.w3c.dom.Node;
 
7
import org.w3c.dom.Element;
 
8
 
 
9
public class oracle_dom2 extends bench {
 
10
    String nsxsi="http://www.w3.org/2001/XMLSchema-instance";
 
11
    String nsenc="http://www.w3.org/2001/12/soap-encoding";
 
12
    String nssoap="http://www.w3.org/2001/12/soap-envelope";
 
13
    String nsopc="http://opcfoundation.org/webservices/OPCDA/";
 
14
    Random generator;
 
15
 
 
16
    public void InitXML(int enlarge) {
 
17
        if (enlarge>0) generator = new Random();
 
18
    }
 
19
 
 
20
    public void ParseXML(int enlarge, int iters, int iter) {
 
21
        XMLDocument doc;
 
22
        Element proot,pnode,node,node1,node2;
 
23
        ByteArrayOutputStream mem = new ByteArrayOutputStream();
 
24
        int i;
 
25
        
 
26
        try {
 
27
            doc = new XMLDocument();
 
28
            proot = doc.createElementNS(nssoap,"Envelope");
 
29
            proot.setAttribute("xmlns",nssoap);
 
30
            proot.setAttribute("xmlns:xsi",nsxsi);
 
31
            proot.setAttribute("xmlns:enc",nsenc);
 
32
            doc.appendChild(proot);
 
33
            pnode = doc.createElementNS(nssoap,"Body");
 
34
            proot.appendChild(pnode);
 
35
 
 
36
    node=doc.createElementNS(nsopc,"WriteResponse");
 
37
    pnode.appendChild(node);pnode=node;
 
38
    node=doc.createElementNS(nsopc,"WriteResult");
 
39
    node.setAttribute("RcvTime","2002-04-29T10:16:26.6806250+02:00");
 
40
    node.setAttribute("ReplyTime","2002-04-29T10:16:26.7806250+02:00");
 
41
    node.setAttribute("ClientRequestHandle","WriteError");
 
42
    node.setAttribute("RevisedLocaleID","en");
 
43
    node.setAttribute("ServerState","running");
 
44
    pnode.appendChild(node);
 
45
    node1=doc.createElementNS(nsopc,"RItemList");
 
46
    pnode.appendChild(node1);
 
47
    node=doc.createElementNS(nsopc,"Errors");
 
48
    node.setAttribute("ID","E_UNKNOWNITEMID");
 
49
    pnode.appendChild(node);
 
50
    node2=doc.createElementNS(nsopc,"Text");
 
51
    node.appendChild(node2);    
 
52
    node2.appendChild(doc.createTextNode("The item does not exist in the server address space."));
 
53
    node=doc.createElementNS(nsopc,"Errors");
 
54
    node.setAttribute("ID","S_CLAMP");
 
55
    pnode.appendChild(node);
 
56
    node2=doc.createElementNS(nsopc,"Text");
 
57
    node.appendChild(node2);    
 
58
    node2.appendChild(doc.createTextNode("The value written was accepted but the output was clamped."));
 
59
 
 
60
    pnode=node1;
 
61
    node=doc.createElementNS(nsopc,"Items");
 
62
    node.setAttribute("ItemPath","");
 
63
    node.setAttribute("ItemName","WrongItemID1");
 
64
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
65
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
 
66
    pnode.appendChild(node);
 
67
    node1=doc.createElementNS(nsopc,"Value");
 
68
    node.appendChild(node1);
 
69
    node.setAttribute("xsi:nil","true");
 
70
 
 
71
    node=doc.createElementNS(nsopc,"Items");
 
72
    node.setAttribute("ItemPath","");
 
73
    node.setAttribute("ItemName","WrongItemID2");
 
74
    node.setAttribute("Timestamp","0001-01-01T00:00:00.0000000+01:00");
 
75
    node.setAttribute("ErrorID","E_UNKNOWNITEMID");
 
76
    pnode.appendChild(node);
 
77
    node1=doc.createElementNS(nsopc,"Value");
 
78
    node.appendChild(node1);
 
79
    node.setAttribute("xsi:nil","true");
 
80
 
 
81
    node=doc.createElementNS(nsopc,"Items");
 
82
    node.setAttribute("ItemPath","/Reals");
 
83
    node.setAttribute("ItemName","Float1");
 
84
    node.setAttribute("ValueType","xsd:float");
 
85
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
86
    pnode.appendChild(node);
 
87
    node1=doc.createElementNS(nsopc,"Value");
 
88
    node.appendChild(node1);
 
89
    node.setAttribute("xsi:type","xsd:float");
 
90
    node1.appendChild(doc.createTextNode("10.0141414"));
 
91
 
 
92
    node=doc.createElementNS(nsopc,"Items");
 
93
    node.setAttribute("ItemPath","/Reals");
 
94
    node.setAttribute("ItemName","Float2");
 
95
    node.setAttribute("ValueType","xsd:float");
 
96
    node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
97
    node.setAttribute("SuccessID","S_CLAMP");
 
98
    pnode.appendChild(node);
 
99
    node1=doc.createElementNS(nsopc,"Value");
 
100
    node.appendChild(node1);
 
101
    node.setAttribute("xsi:type","xsd:float");
 
102
    node1.appendChild(doc.createTextNode("1.07"));
 
103
    
 
104
    for (i=0;i<enlarge;i++) {
 
105
        node=doc.createElementNS(nsopc,"Items");
 
106
        node.setAttribute("ItemPath","/Integer");
 
107
        node.setAttribute("ItemName","IntN");
 
108
        node.setAttribute("ValueType","xsd:int");
 
109
        node.setAttribute("Timestamp","2002-04-29T11:47:18.1493750+02:00");
 
110
        node.setAttribute("SuccessID","S_CLAMP");
 
111
        pnode.appendChild(node);
 
112
        node1=doc.createElementNS(nsopc,"Value");
 
113
        node.appendChild(node1);
 
114
        node.setAttribute("xsi:type","xsd:int");
 
115
        node1.appendChild(doc.createTextNode(Integer.toString(generator.nextInt())));
 
116
    }
 
117
            doc.print(mem);
 
118
        }
 
119
        catch (Exception e)
 
120
        {
 
121
            System.out.println(e.toString());
 
122
        }
 
123
 
 
124
//      if (iter==iters) System.out.println(mem);
 
125
    }
 
126
 
 
127
    static public void main(String argv[]) throws IOException {
 
128
        bench mybench = new oracle_dom2();
 
129
        mybench.Bench(argv);
 
130
    }
 
131
    
 
132
}
 
 
b'\\ No newline at end of file'