/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 validate/sun_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 javax.xml.parsers.DocumentBuilderFactory; 
 
5
import javax.xml.parsers.DocumentBuilder; 
 
6
 
 
7
public class sun_dom2 extends bench {
 
8
    DocumentBuilderFactory factory;
 
9
    DocumentBuilder parser;
 
10
    final String JAXP_SS="http://java.sun.com/xml/jaxp/properties/schemaSource";
 
11
    final String JAXP_SL="http://java.sun.com/xml/jaxp/properties/schemaLanguage";
 
12
    final String W3C_Schema="http://www.w3.org/2001/XMLSchema";
 
13
 
 
14
    
 
15
    public void InitXML() {
 
16
            factory = DocumentBuilderFactory.newInstance();
 
17
            factory.setNamespaceAware(false);
 
18
            factory.setValidating(false);
 
19
            try {
 
20
                parser = factory.newDocumentBuilder();
 
21
            }
 
22
            catch (Throwable err) {
 
23
                err.printStackTrace ();
 
24
                return;
 
25
            }
 
26
 
 
27
    }
 
28
    
 
29
    public void InitXML_Validation() {
 
30
            factory = DocumentBuilderFactory.newInstance();
 
31
            factory.setNamespaceAware(true);
 
32
            factory.setValidating(true);
 
33
            try {
 
34
                factory.setAttribute(JAXP_SL,W3C_Schema);
 
35
            }
 
36
            catch (IllegalArgumentException x) {
 
37
                System.out.println("JAXP 1.2 Unsupported!");
 
38
            }
 
39
 
 
40
//          factory.setAttribute(JAXP_SS,new File("test.xsd"));
 
41
            try {
 
42
                parser = factory.newDocumentBuilder();
 
43
            }
 
44
            catch (Throwable err) {
 
45
                err.printStackTrace ();
 
46
                return;
 
47
            }
 
48
 
 
49
    }
 
50
 
 
51
    
 
52
    public void ParseXML(FileInputStream is, int iters, int iter) {
 
53
        try {
 
54
            parser.parse(is);           
 
55
        }
 
56
        catch (Exception e)
 
57
        {
 
58
            System.out.println(e.toString());
 
59
        }
 
60
    }
 
61
 
 
62
    public void ValidateXML(FileInputStream is, int iters, int iter) {
 
63
        try {
 
64
            parser.parse(is);           
 
65
        }
 
66
        catch (Exception e)
 
67
        {
 
68
            System.out.println(e.toString());
 
69
        }
 
70
    }
 
71
    
 
72
    static public void main(String argv[]) throws IOException {
 
73
        bench mybench = new sun_dom2();
 
74
        mybench.Bench(argv);
 
75
    }
 
76
}
 
 
b'\\ No newline at end of file'