75 InputSource source = new InputSource(new StringReader("<?xml version='1.0' encoding='utf-8'?>"));
76 parser.parse(source, new MyHandler());
77 Assert.fail("Inputstream without document element accepted");
78 } catch (Exception ex) {
79 System.out.println("Exception thrown: " + ex.getMessage());
80 // Premature end of file exception expected
81 }
82 }
83
84 static class MyHandler extends DefaultHandler {
85 public void startDocument() {
86 System.out.println("Start document called");
87 }
88
89 public void endDocument() {
90 System.out.println("End document called");
91 }
92 }
93
94 }
95
|
75 InputSource source = new InputSource(new StringReader("<?xml version='1.0' encoding='utf-8'?>"));
76 parser.parse(source, new MyHandler());
77 Assert.fail("Inputstream without document element accepted");
78 } catch (Exception ex) {
79 System.out.println("Exception thrown: " + ex.getMessage());
80 // Premature end of file exception expected
81 }
82 }
83
84 static class MyHandler extends DefaultHandler {
85 public void startDocument() {
86 System.out.println("Start document called");
87 }
88
89 public void endDocument() {
90 System.out.println("End document called");
91 }
92 }
93
94 }
|