public PMML unmarshalPMML(File file) throws JAXBException, SAXException, IOException { Unmarshaller unmarshaller = createUnmarshaller(); try(InputStream is = new FileInputStream(file)){ Source source = SAXUtil.createFilteredSource(is, new ImportFilter()); return (PMML)unmarshaller.unmarshal(source); } }
/** * @see JAXBUtil#unmarshalPMML(Source) */ static public PMML unmarshal(InputStream is) throws SAXException, JAXBException { Source source = SAXUtil.createFilteredSource(is, new ImportFilter()); return JAXBUtil.unmarshalPMML(source); }
/** * @see JAXBUtil#unmarshalPMML(Source) */ static public PMML unmarshal(InputStream is) throws SAXException, JAXBException { Source source = SAXUtil.createFilteredSource(is, new ImportFilter()); return JAXBUtil.unmarshalPMML(source); }
public LoadingModelEvaluatorBuilder load(InputStream is, String modelName) throws SAXException, JAXBException { Schema schema = getSchema(); ValidationEventHandler validationEventHandler = getValidationEventHandler(); List<? extends XMLFilter> filters = getFilters(); boolean locatable = getLocatable(); VisitorBattery visitors = getVisitors(); Unmarshaller unmarshaller = JAXBUtil.createUnmarshaller(); unmarshaller.setSchema(schema); unmarshaller.setEventHandler(validationEventHandler); if(filters == null){ filters = Collections.singletonList(new ImportFilter()); } Source source = SAXUtil.createFilteredSource(is, filters.toArray(new XMLFilter[filters.size()])); PMML pmml = (PMML)unmarshaller.unmarshal(source); Visitor locatorHandler = (locatable ? new LocatorTransformer() : new LocatorNullifier()); locatorHandler.applyTo(pmml); if(visitors != null && visitors.size() > 0){ visitors.applyTo(pmml); } Model model = PMMLUtil.findModel(pmml, modelName); setPMML(pmml); setModel(model); return this; }
@Test public void filter() throws Exception { PMML pmml = ResourceUtil.unmarshal(ExtensionFilterTest.class, new ImportFilter()); pmml = ResourceUtil.unmarshal(ExtensionFilterTest.class, new ImportFilter(false)); pmml = ResourceUtil.unmarshal(ExtensionFilterTest.class, new ImportFilter(), new ExtensionFilter());