private SpringApplicationService parse(final InputStream xml) throws JAXBException {
Assert.notNull(xml);
final JAXBContext jc = JAXBContext.newInstance(SpringApplicationService.class);
final Unmarshaller u = jc.createUnmarshaller();
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final ByteArrayOutputStream bos = new ByteArrayOutputStream(512);
generateSchema(bos);
try {
final SpringApplicationService springApplicationService = (SpringApplicationService) u.unmarshal(xml);
final Schema schema = schemaFactory.newSchema(new StreamSource(new ByteArrayInputStream(bos.toByteArray())));
final Validator validator = schema.newValidator();
validator.validate(new JAXBSource(jc, springApplicationService));
return springApplicationService;
} catch (SAXException | IOException e) {
throw new IllegalArgumentException("Failed to parse XML. The XML must conform to the following schema:\n" + bos, e);