Schema { public static CDDef readDefinition(String fileName) throws Exception {{ return readDefinition(fileName, null); }} public static CDDef readDefinition(String fileName, CDDef def) throws Exception {{ Schema schema; // Open the specified schema-definition file and parse its contents to // create the schema object. But before parsing it, pre-process it to // remove comments, etc. and make changes necessary for the parser. try { BufferedReader reader = new BufferedReader(new FileReader(fileName)); schema = parse(Preprocessor.preProcessSchemaDefinition(reader)); } catch (FileNotFoundException e) { throw new Exception("Schema definition file '" + fileName + "'" + " not accessible"); } catch (IOException e) { throw new Exception("Error in reading schema definition file '" + fileName + "'"); } /* schema.print(); System.out.println(); */ // Create an empty CDDef object if none already exists if (def == null) def = CDDef.parse(" ( ) ( )"); // Traverse the schema object to extract the element, attribute and // type definitions SchemaVisitor sv = new SchemaVisitor(def); schema.processDefinition(sv); String errors = sv.getErrors(); if (!errors.equals("")) throw new Exception(errors); String namespacePrefixes[] = sv.getNamespacePrefix(); /* def.print(); System.out.println(); */ return def; }} traversal processDefinition(SchemaVisitor) { bypassing -> *,tail,* to *; } // use for debugging public void print() bypassing -> *,tail,* to * (DisplayVisitor); }