public void transform ( Source pIn ) throws JspException { try { // Create transformer Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( getSource ( mStylesheetURI ) ) ; // Store temporary output in a bytearray, as the transformer will // usually try to flush the stream (illegal operation from a custom // tag). ByteArrayOutputStream os = new ByteArrayOutputStream ( ) ; StreamResult out = new StreamResult ( os ) ; // Perform the transformation transformer . transform ( pIn , out ) ; // Write the result back to the JSP writer pageContext . getOut ( ) . print ( os . toString ( ) ) ; } catch ( MalformedURLException murle ) { throw new JspException ( murle . getMessage ( ) , murle ) ; } catch ( IOException ioe ) { throw new JspException ( ioe . getMessage ( ) , ioe ) ; } catch ( TransformerException te ) { throw new JspException ( "XSLT Trandformation failed: " + te . getMessage ( ) , te ) ; } }
Performs the transformation and writes the result to the JSP writer .