Creating the MyXSLTTransformer Application
MyXSLTTransformer is a simple Java application that uses a DOM parser to create a Document object from the CarParts.xml file. This Document object is converted to a DOMSource object and used by the Transformer object as the source. Because the output is to be displayed on the screen, System.out is used as the output of the transformation. The Transformer object itself is created by using the CarParts.xsl stylesheet.
First you need to import the necessary packages and classes. To do so, add the following lines of code:
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.FactoryConfigurationError; import javax.xml.parsers.ParserConfigurationException; ...
Get Java™ APIs for XML Kick Start 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.