Studying Example
Next an instance of TransformerFactory is created. The TransformerFactory is responsible for creating Transformer and Template objects. In our example, we create a Transformer object. Transformer objects are not
The transformer instance is then used to perform the actual transformation. It applies the XSLT stylesheet to the XML data, sending the result to the target file.
XSLT support packages in JAXP
JAXP support for XSLT is broken down into the packages listed below:
javax.xml.transform: defines a general purpose API for XML transformations without any dependencies on SAX or DOM. The Transformer class is obtained from the TransformerFactory class. The Transformer transforms from a source to a result.
javax.xml.transform.dom: defines how transformations can be performed using DOM. It also provides implementations of Source and Result:
DOMSource and DOMResult.
javax.xml.transform.sax: supports SAX2 transformations. It defines SAX
versions of Source and Result: SAXSource and SAXResult. It also defines a subclass of TransformerFactory that allows SAX2 events to be fed into an XSLT processor.
javax.xml.transform.stream: defines I/O stream implementations of Source
and Result: StreamSource and StreamResult.
The heart of JAXP XSLT support lies in the javax.xml.transform package, which lays out the mechanics and overall process for any transformation that is performed.
Chapter 3. Processing XML 67