@Override public void activateObject(Validator obj) throws Exception { obj.reset(); } @Override
@Override public void activateObject(Validator obj) throws Exception { obj.reset(); } @Override
public static ValidationResult validate(Document doc, Source... schemas) throws IOException, SAXException { XMLErrorHandler errorHandler = new XMLErrorHandler(); Validator validator = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemas).newValidator(); try { validator.setErrorHandler(errorHandler); validator.validate(new DOMSource(doc)); return errorHandler; } finally { validator.reset(); } }
@SuppressWarnings("finally") public InputStream validating(InputStream src) { try { TempStream temp = TempStream.getInstance(src); try { validators.get().validate(new StreamSource(temp.readStream())); } catch (Exception e) { try { temp.close(); } finally { throw e; } } return temp; } catch (Exception e) { throw new RuntimeException("Error validating stream", e); } finally { validators.get().reset(); } }
protected void doProcess(Packet packet) throws SAXException { getValidator().reset(); Class<? extends ValidationErrorHandler> handlerClass = feature.getErrorHandler(); ValidationErrorHandler handler; try { handler = handlerClass.newInstance(); } catch(Exception e) { throw new WebServiceException(e); } handler.setPacket(packet); getValidator().setErrorHandler(handler); Message msg = packet.getMessage().copy(); Source source = msg.readPayloadAsSource(); try { // Validator javadoc allows ONLY SAX, and DOM Sources // But the impl seems to handle all kinds. getValidator().validate(source); } catch(IOException e) { throw new WebServiceException(e); } }
protected void doProcess(Packet packet) throws SAXException { getValidator().reset(); Class<? extends ValidationErrorHandler> handlerClass = feature.getErrorHandler(); ValidationErrorHandler handler; try { handler = handlerClass.newInstance(); } catch(Exception e) { throw new WebServiceException(e); } handler.setPacket(packet); getValidator().setErrorHandler(handler); Message msg = packet.getMessage().copy(); Source source = msg.readPayloadAsSource(); try { // Validator javadoc allows ONLY SAX, and DOM Sources // But the impl seems to handle all kinds. getValidator().validate(source); } catch(IOException e) { throw new WebServiceException(e); } }
protected void doProcess(Packet packet) throws SAXException { getValidator().reset(); Class<? extends ValidationErrorHandler> handlerClass = feature.getErrorHandler(); ValidationErrorHandler handler; try { handler = handlerClass.newInstance(); } catch(Exception e) { throw new WebServiceException(e); } handler.setPacket(packet); getValidator().setErrorHandler(handler); Message msg = packet.getMessage().copy(); Source source = msg.readPayloadAsSource(); try { // Validator javadoc allows ONLY SAX, and DOM Sources // But the impl seems to handle all kinds. getValidator().validate(source); } catch(IOException e) { throw new WebServiceException(e); } }