Parsing the XML document
Create a DocumentBuilderFactory
object using the static method newInstance()
. The factory class is used to create a DocumentBuilder
parser.
DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
Create a DocumentBuilder
parser from the DocumentBuilderFactory
object using the newDocumentBuilder()
method.
DocumentBuilder builder = factory.newDocumentBuilder();
Parse the example XML document using one of the overloaded parse()
methods.
File xmlFile = new File("catalog.xml"); Document document = builder.parse(xmlFile);
Generating the XSL-FO document
Create a TransformerFactory
object using the static method newInstance()
. The factory class is used to create a Transformer
object.
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Create a Transformer
object from the TransformerFactory
object using the newTransformer()
method.
File stylesheet = new File("catalog.xsl"); Transformer transformer = transformerFactory.newTransformer(new StreamSource...