public PMML loadModel ( String model , InputStream source ) { try { if ( schema == null ) { visitorBuildResults . add ( new PMMLWarning ( ResourceFactory . newInputStreamResource ( source ) , "Could not validate PMML document, schema not available" ) ) ; } final JAXBContext jc ; final ClassLoader ccl = Thread . currentThread ( ) . getContextClassLoader ( ) ; XMLStreamReader reader = null ; try { Thread . currentThread ( ) . setContextClassLoader ( PMML4Compiler . class . getClassLoader ( ) ) ; Class c = PMML4Compiler . class . getClassLoader ( ) . loadClass ( "org.dmg.pmml.pmml_4_2.descr.PMML" ) ; jc = JAXBContext . newInstance ( c ) ; XMLInputFactory xif = XMLInputFactory . newFactory ( ) ; xif . setProperty ( XMLInputFactory . IS_SUPPORTING_EXTERNAL_ENTITIES , false ) ; xif . setProperty ( XMLInputFactory . SUPPORT_DTD , true ) ; reader = xif . createXMLStreamReader ( source ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( ccl ) ; } Unmarshaller unmarshaller = jc . createUnmarshaller ( ) ; if ( schema != null ) { unmarshaller . setSchema ( schema ) ; } if ( reader != null ) { return ( PMML ) unmarshaller . unmarshal ( reader ) ; } else { this . results . add ( new PMMLError ( "Unknown error in PMML" ) ) ; return null ; } } catch ( ClassNotFoundException | XMLStreamException | JAXBException e ) { this . results . add ( new PMMLError ( e . toString ( ) ) ) ; return null ; } }
Imports a PMML source file returning a Java descriptor