package pt.utl.ist.sotis.dblp.conversion; import generated.Dblp; import java.io.File; import javax.xml.XMLConstants; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import org.xml.sax.SAXException; import pt.utl.ist.sotis.conversion.ConversionException; public class DblpUnmarshaller { public static JAXBElement parse(File xml) throws ConversionException { try { JAXBContext jc = JAXBContext.newInstance("generated"); Unmarshaller unmarshaller = jc.createUnmarshaller(); Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema( DblpUnmarshaller.class.getResource("/dblp.xsd")); unmarshaller.setSchema(schema); return (JAXBElement) unmarshaller.unmarshal(xml); } catch (JAXBException e) { throw new ConversionException(e); } catch (SAXException e) { throw new ConversionException(e); } } }