Xalan implements the W3C Recommendation 16 November 1999 XSL Transformations (XSLT) Version 1.0.

XLST is a stylesheet language for transforming XML documents into other XML documents, HTML documents, or other document types. The language includes the XSL Transformation vocabulary and XPath, a language for addressing parts of an XML document. An XSL stylesheet describes how to transform the tree of nodes in the XML input into another tree of nodes.

Basic procedure for performing transformations:

  1. Use one of the {@link org.apache.xalan.xslt.XSLTProcessorFactory} static getProcessor methods to instantiate an {@link org.apache.xalan.xslt.XSLTProcessor}.

    By default, the XSLTProcessor uses the {@link org.apache.xalan.xpath.dtm.DTMLiaison} and the high-performance DTM (Document Table Model) "pseudo" DOM parser to process the input. If your input or output is a DOM node (rather than a URL, file, or stream), Xalan uses {@link org.apache.xalan.xpath.xdom.XercesLiaison XercesLiaison} and the Xerces DOM parser.

    The XSLT and XPath engines are independent from any given DOM or XML implementation. All parser-dependent calls are funneled through the {@link org.apache.xalan.xpath.xml.XMLParserLiaison}.

  2. Set up {@link org.apache.xalan.xslt.XSLTInputSource} objects for the XML input and XSL stylesheet. You can use a file name or URL, character stream, byte stream, or SAX input stream to instantiate an XSLTInputSource object.

    If the XML document contains a stylesheet Processing Instruction (PI), you do not need to create a separate XSLTInputSource object for an XSL stylesheet.

    Note: For improved performance with a series of transformations, use the XSLTProcessor processStylesheet method to compile the XSL stylesheet. The result is a {@link org.apache.xalan.xslt.StylesheetRoot} object with its own process() method for performing transformations. Compiling the stylesheet is also useful when you need to get information from the stylesheet before the transformation occurs. You also must compile the stylesheet if you are using the XSLTProcessor as a SAX document handler.

  3. Set up an {@link org.apache.xalan.xslt.XSLTResultTarget} for the transformation output. You can use a file name or URL, character stream, byte stream, or SAX document handler to instantiate an XSLTResultTarget object.

  4. Use the XSLTProcessor or (if you have compiled the stylesheet) the(@link org.apache.xalan.xslt.StylesheetRoot} process method to perform the transformation.

    Xalan is thread-safe for one instance per thread. If you are using the same instance of XSLTProcessor to perform more than one transformation, call the reset method between transformations.

For an introduction to basic usage patterns, see Usage Patterns.