Transformer class is having transform() method to apply XSLT on XML to do transformation, during transformation process if any fatalErrors, errors or warnings, to handle these following are steps.
· Write an XSLTErrorAdaptor which Implement ErrorListener
· Provide a implementation to error(), fatalError() and warning().
· Implement these methods to build error message using StringBuffer and set Boolean flag to true.
· Register XSLTErrorAdaptor to the Transformer class in Client application before calling transform()
transformer. setErrorListener(adaptor);
transformer. transform(Source xmlSource, Result outputTarget)
· Check value of flag defined in adaptor, if flag is true call a rollback() method to clean up the process and return a error message in StringBuffer.