XMLDoc { public static XMLDoc XMLparse(String in) throws Exception {{ String errors; XMLDoc doc = parse(Preprocessor.process(in)); errors = doc.init(); if (!errors.equals("")) throw new ParseException(errors); errors = doc.validate(); if (!errors.equals("")) throw new ParseException(errors); return doc; }} public static XMLDoc XMLparse(InputStream in) throws Exception {{ return XMLparse(readContent(in)); }} public static XMLDoc XMLparse(Reader in) throws Exception {{ return XMLparse(readContent(in)); }} private static String readContent(InputStream in) throws Exception {{ String text = ""; try { byte buf[] = new byte[1000]; while (true) { int size = in.read(buf); if (size <= 0) break; String line = new String(buf, 0, size); text = text + line; } in.close(); return text; } catch (IOException e) { throw new Exception("Error in reading input"); } }} private static String readContent(Reader in) throws Exception {{ BufferedReader r = new BufferedReader(in); String text = ""; try { while (true) { String line = r.readLine(); if (line == null) break; if (!text.equals("")) text = text + "\n"; text = text + line; } r.close(); return text; } catch (IOException e) { throw new Exception("Error in reading input"); } }} public String init() bypassing -> *,tail,* to * (InitVisitor); public String validate() bypassing -> *,tail,* to * (ValidateVisitor); public void print() bypassing -> *,tail,* to * (DisplayVisitor); } // end of class XMLDoc