XBELValidatingConverter extends XBELConverter { @Override public XBELDocument unmarshal(final String str) throws JAXBException, IOException { try { validator.validate(str); } catch (SAXException e) { throw new JAXBException(e); } return super.unmarshal(str); } XBELValidatingConverter(); @Override String marshal(final XBELDocument d); @Override XBELDocument unmarshal(final String str); @Override XBELDocument unmarshal(File f); @Override XBELDocument unmarshal(Source s); final static String SCHEMA_PATH; final static String XBEL_SCHEMA; final static String XBEL_ANNO; }
@Test public void testTemplate() { final String testxml = XML_ROOT + "beldocument_template.xbel"; final File testFile = new File(testxml); if (!testFile.canRead()) fail("can't read " + testxml); try { XBELDocument d = xvc.unmarshal(testFile); assertNotNull(d); } catch (JAXBException e) { String err = "JAXB exception unmarshalling " + testxml; err += ", exception message follows:\n\t"; err += e.getMessage(); fail(err); } catch (IOException e) { String err = "IO exception unmarshalling " + testxml; err += ", exception message follows:\n\t"; err += e.getMessage(); fail(err); } }