static public Object deserialiseObject ( String xml , String xsdFile , Class < ? > objclass ) throws JAXBException , SAXException , XMLStreamException { Object obj = null ; JAXBContext jaxbContext = getJAXBContext ( objclass ) ; SchemaFactory schemaFactory = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; final String schemaResourceFilename = new String ( xsdFile ) ; URL schemaURL = MalmoMod . class . getClassLoader ( ) . getResource ( schemaResourceFilename ) ; Schema schema = schemaFactory . newSchema ( schemaURL ) ; Unmarshaller jaxbUnmarshaller = jaxbContext . createUnmarshaller ( ) ; jaxbUnmarshaller . setSchema ( schema ) ; StringReader stringReader = new StringReader ( xml ) ; XMLInputFactory xif = XMLInputFactory . newFactory ( ) ; xif . setProperty ( XMLInputFactory . IS_SUPPORTING_EXTERNAL_ENTITIES , false ) ; xif . setProperty ( XMLInputFactory . SUPPORT_DTD , false ) ; XMLStreamReader XMLreader = xif . createXMLStreamReader ( stringReader ) ; obj = jaxbUnmarshaller . unmarshal ( XMLreader ) ; return obj ; }
Attempt to construct the specified object from this XML string