Using XSLT Without DOM
Although you often might find it useful to load DOM trees before applying style sheets, many times, you already have an XML document and a style sheet and you just want to perform the transform. In these cases, you can use a stream source and a stream result to simply perform the transform without an intermediate DOM representation.
Listing 10.10 shows a JSP that uses getResourceAsStream and a Transformer to apply a style sheet without using DOM at all.
Listing 10.10. Source Code for applyxslt3.jsp
<%@ page contentType=”text/html” %><%@ page import=”javax.xml.parsers.*,org.w3c.dom.*” %><%@ page import=”javax.xml.transform.*,javax.xml.transform.dom.*” %><%@ page import=”javax.xml.transform.stream.*,java.io.*” %><% // Create ... |
Get Special Edition Using XSLT now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.