Java API for XML Processing: Difference between revisions

Content deleted Content added
m Undid revision 220598401 by 98.207.48.163 (talk)
XSLT interface: fleshed out the information about the JAXP transformation API
Line 33:
== XSLT interface ==
 
The '''X'''ML '''S'''tylesheet '''L'''anguage for '''T'''ransformations, or '''[[XSLT]]''', allows for conversion of an XML document into other forms of data. JAXP provides interfaces in package javax.xml.transform allowing applications to invoke an XSLT transformation. This interface was originally called TrAX (Transformation API for XML), and was developed by an informal collaboration between the developers of a number of Java XSLT processors.
 
Main features of the interface are:
 
* a factory class allowing the application to select dynamically which XSLT processor it wishes to use
 
* methods on the factory class to create a Templates object, representing the compiled form of a stylesheet. This is a thread-safe object that can be used repeatedly, in series or in parallel, to apply the same stylesheet to multiple source documents (or to the same source document with different parameters)
 
* a method on the Templates object to create a Transformer, representing the executable form of a stylesheet. This cannot be shared across threads, though it is serially reusable. The Transformer provides methods to set stylesheet parameters and serialization options (for example, whether output should be indented), and a method to actually run the transformation.
 
Two abstract interfaces Source and Result are defined to represent the input and output of the transformation. This is a somewhat unconventional use of Java interfaces, since there is no expectation that a processor will accept any class that implements the interface - each processor can choose which kinds of Source or Result it is prepared to handle. In practice all JAXP processors support the three standard kinds of Source (DOMSource, SAXSource, StreamSource) and the three standard kinds of Result (DOMResult, SAXResult, StreamResult) and possibly other implementations of their own.
 
== External links ==