TrAX
Unfortunately, there is no standard API for XSLT that works across languages and engines: each vendor provides its own unique API. The closest thing to a standard XSLT API is the Transformations API for XML (TrAX), included in JAXP. However, this is limited to Java and is not even supported by all Java-based XSLT engines. Nonetheless, since it is the closest thing to a standard there is, we will discuss it here.
Code that transforms an XML document using an XSLT stylesheet
through TrAX follows these six steps. All of the classes mentioned are
in the javax.xml.transform package,
a standard part of Java 1.4 and later and a separately installable
option in earlier versions.
Call the
TransformerFactory.newInstance( )factory method to create a newTransformerFactoryobject.Construct a
Sourceobject from the XSLT stylesheet.Pass this
Sourceobject to theTransformerFactoryobject’snewTransform( )method to create aTransformobject.Construct a
Sourceobject from the input XML document you wish to transform.Construct a
Resultobject into which the transformed XML document will be output.Pass the
Sourceand theResultto theTransformobject’stransform( )method.
The source can be built from a DOM Document object,
a SAX InputSource, or an InputStream—represented by the javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, and
javax.xml.transform.stream.StreamSource
classes, respectively. The result of the transform can be a DOM
Document object, a SAX ContentHandler ...