Code example for SAXSource

0
                final Transformer transformer = request.needTransform()
                        ? createTransformer(realPath)
                        : null; 
                if (transformer != null) {
                    response.setContentType(TEXT_HTML);
                    final Source saxSource = new SAXSource(yaletFilter, inputSource);
                    transformer.transform(saxSource, new StreamResult(stream));
                } else { 
                    response.setContentType(TEXT_XML);
                    yaletFilter.setContentHandler(new MyXMLSerializer(stream));
                    yaletFilter.parse(inputSource);
                } 
            } finally { 
                stream.close();
            } 
 
            final String redir = response.getRedir();
            if (response.isProcessed()) {
                log.info("Content-Type: " + response.getContentType());
            } else if (redir == null || !response.getErrors().isEmpty()) {
                response.getOutputStream().write(stream.toByteArray());