Now that you know how to create a JSP and load DOM documents, you are ready to apply style sheets to the documents. You have already seen how to use the TransformerFactory to create a Transformer object, so the only missing piece of the puzzle is how you tell the Transformer about your style sheet.
As it turns out, you just need to supply a Source (StreamSource, DOMSource, and so on) when you create the Transformer. For example, if you have a style sheet in /home/mark/style.xsl, you create the Transformer this way:
Transformer trans = tf.newTransformer( new StreamSource(new File(“/home/mark/style.xsl”)));
Listing 10.7 shows a JSP that applies a style sheet to an XML document and displays HTML output. Notice that ...