/** * Takes input XML file and unmarshalls it * * @throws JAXBException, FileNotFoundException, SiriusException * @returns Scenario */ public edu.berkeley.path.beats.jaxb.Scenario readAndUnmarshallXML() throws JAXBException, FileNotFoundException, BeatsException { JAXBContext jaxbContext = JAXBContext.newInstance("edu.berkeley.path.beats.jaxb"); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); javax.xml.validation.Schema schema = this.getSchema(); jaxbUnmarshaller.setSchema(schema); edu.berkeley.path.beats.simulator.ObjectFactory.setObjectFactory( jaxbUnmarshaller, new JaxbObjectFactory()); Scenario scenario = (Scenario) jaxbUnmarshaller.unmarshal(new FileInputStream(this.inputFileName)); return scenario; }
Context(Class clazz) { try { jaxbContext = JAXBContext.newInstance(clazz); marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setSchema(null); unmarshaller = jaxbContext.createUnmarshaller(); unmarshaller.setSchema(null); } catch (JAXBException e) { e.printStackTrace(); } }