private GeneratorMain loadXMLSpecification ( ) { try { DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; dbf . setFeature ( "http://apache.org/xml/features/nonvalidating/load-external-dtd" , false ) ; URL url = ClassLoader . getSystemResource ( GENERATOR_SCHEMA_FILE ) ; if ( url != null ) { try { Schema schema = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) . newSchema ( url ) ; dbf . setSchema ( schema ) ; dbf . setIgnoringElementContentWhitespace ( true ) ; } catch ( Exception e ) { LOG . warning ( "Could not set up XML Schema validation for specification file." , e ) ; } } else { LOG . warning ( "Could not set up XML Schema validation for specification file." ) ; } Document doc = dbf . newDocumentBuilder ( ) . parse ( specfile ) ; Node root = doc . getDocumentElement ( ) ; if ( TAG_DATASET . equals ( root . getNodeName ( ) ) ) { GeneratorMain gen = new GeneratorMain ( ) ; processElementDataset ( gen , root ) ; return gen ; } else { throw new AbortException ( "Experiment specification has incorrect document element: " + root . getNodeName ( ) ) ; } } catch ( FileNotFoundException e ) { throw new AbortException ( "Can't open specification file." , e ) ; } catch ( SAXException e ) { throw new AbortException ( "Error parsing specification file." , e ) ; } catch ( IOException e ) { throw new AbortException ( "IO Exception loading specification file." , e ) ; } catch ( ParserConfigurationException e ) { throw new AbortException ( "Parser Configuration Error" , e ) ; } }
Load the XML configuration file .