@Override public Hdr unmarshal( java.io.InputStream is ) throws JAXBException { try { log.info("For MDP, unmarshall via binder"); // InputStream to Document javax.xml.parsers.DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); org.w3c.dom.Document doc = dbf.newDocumentBuilder().parse(is); // binder = jc.createBinder(); JaxbValidationEventHandler eventHandler = new JaxbValidationEventHandler(); eventHandler.setContinue(false); binder.setEventHandler(eventHandler); try { jaxbElement = (Hdr) binder.unmarshal( doc ); } catch (UnmarshalException ue) { log.info("encountered unexpected content; pre-processing"); eventHandler.setContinue(true); DOMResult result = new DOMResult(); Templates mcPreprocessorXslt = JaxbValidationEventHandler.getMcPreprocessor(); XmlUtils.transform(doc, mcPreprocessorXslt, null, result); doc = (org.w3c.dom.Document)result.getNode(); jaxbElement = (Hdr) binder.unmarshal( doc ); } return jaxbElement; } catch (Exception e ) { e.printStackTrace(); return null; } } /** * @since 2.7.1 */ @Override public Hdr unmarshal(org.w3c.dom.Element el) throws JAXBException { try { binder = jc.createBinder(); JaxbValidationEventHandler eventHandler = new JaxbValidationEventHandler(); eventHandler.setContinue(false); binder.setEventHandler(eventHandler); try { jaxbElement = (Hdr) binder.unmarshal( el ); } catch (UnmarshalException ue) { log.info("encountered unexpected content; pre-processing"); try { org.w3c.dom.Document doc; if (el instanceof org.w3c.dom.Document) { doc = (org.w3c.dom.Document) el; } else { // Hope for the best. Dodgy though; what if this is // being used on something deep in the tree? // TODO: revisit doc = el.getOwnerDocument(); } eventHandler.setContinue(true); DOMResult result = new DOMResult(); Templates mcPreprocessorXslt = JaxbValidationEventHandler .getMcPreprocessor(); XmlUtils.transform(doc, mcPreprocessorXslt, null, result); doc = (org.w3c.dom.Document) result.getNode(); jaxbElement = (Hdr) binder .unmarshal(doc); } catch (Exception e) { throw new JAXBException("Preprocessing exception", e); } } return jaxbElement; } catch (JAXBException e) { log.error(e); throw e; } }