private static void transform ( final String xmlFileName , final String xsltFileName , final String outputFileName ) { Source xsltSource = null ; if ( StringUtils . isNotBlank ( xsltFileName ) ) { // Use the given stylesheet. xsltSource = new StreamSource ( new File ( xsltFileName ) ) ; } else { // Use the default stylesheet. xsltSource = new StreamSource ( Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( DEFAULT_XSLT_SHEET ) ) ; } // Transform the given input file and put the result in the given output file. final Source xmlSource = new StreamSource ( new File ( xmlFileName ) ) ; final Result xmlResult = new StreamResult ( new File ( outputFileName ) ) ; XmlUtils . transform ( xmlSource , xsltSource , xmlResult ) ; }
Perform the transformation called from the main method .