Programming XML Transformations

Programming XML transformations involves creating an object instance of the Transformer class. The Transformer object will be responsible for reading the XSLT instructions, reading the XML source document, and producing the output.

The creation of the Transformer object must be done through the TransformerFactory class. The TransformerFactory class can create the Transformer object directly, using the XSLT script as a parameter, or else a Templates object can be created using the XSLT script and then the Transformer object can be created using the Templates object. The second approach has the advantage of convenience and creates a thread-safe implementation of the template class.

The code example shown below uses ...

Get J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.