JSTL « Java Tutorial. XSL Transformations (XSLT) Abstract This specification defines the syntax and semantics of XSLT, which is a language for transforming XML documents into other XML documents. XSLT is designed for use as part of XSL, which is a stylesheet language for XML. In addition to XSLT, XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML document by using XSLT to describe how the document is transformed into another XML document that uses the formatting vocabulary. XSLT is also designed to be used independently of XSL. Status of this document This document has been reviewed by W3C Members and other interested parties and has been endorsed by the Director as a W3C Recommendation.
The list of known errors in this specification is available at Comments on this specification may be sent to xsl-editors@w3.org; archives of the comments are available. The English version of this specification is the only normative version. Table of contents. XSLT Reference. XSLT Tutorial. XSLT Processing with Java. XSLT Processing with Java Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9 Feeding JDOM Output into JAXP The DOM API is tedious to use, so many Java programmers opt for JDOM instead.
The typical usage pattern is to generate XML dynamically using JDOM and then somehow transform that into a web page using XSLT. This presents a problem because JAXP does not provide any direct implementation of the javax.xml.Source interface that integrates with JDOM. There are at least three available options: Use org.jdom.output.SAXOutputter to pipe SAX 2 events from JDOM to JAXP.Use org.jdom.output.DOMOutputter to convert the JDOM tree to a DOM tree, and then use javax.xml.transform.dom.DOMSource to read the data into JAXP.
JDOM to SAX approach The SAX approach is generally preferable to other approaches. In support of SAX, JDOM offers the org.jdom.output.SAXOutputter class. JDOM to DOM approach The DOM approach is generally a little slower and will not work if JDOM uses a different DOM implementation than JAXP. The Future of XML Processing. Mark A. Ziesemer: XML and XSLT Tips and Tricks for Java. 1. Get the latest versions Starting with Java 1.4, the Java runtime has included a default XML parser and transformer implementation as part of the Java API for XML Processing (JAXP). However, the included versions aren't up-to-date - not even to the latest versions available when each Java version was released.
As of this writing, the latest Apache Xerces2-J version is 2.9.1 (2.11.0 as of November 2010), and the latest Apache Xalan-J version is 2.7.1. 2. Most of the JAXP interfaces are not thread-safe, including the factories and the instances obtained from them. The same applies to a Transformer. The solution is to use a Templates object, which can be thought of as a compiled-form of a stylesheet. Here is some simple, typical code of performing a transformation without a Templates object: Here is the improved code, which makes use of a reusable Templates object: TransformerFactory tf = TransformerFactory.newInstance(); if(! 3. Most transformations are based on a series of SAX events. 4.
<? Convert HTML content to PDF format. Making Web content available as PDF is one way to facilitate the dissemination of content. In some industries, providing access to print-formatted documents, such as employee benefit descriptions, is mandatory. The law actually dictates that summary plan descriptions (SPDs) be made available in print format even though the content may be provided online. Just printing the Webpage is not sufficient because the print format must include a table of contents with page number references. To add such functionality to a Webpage, developers can convert the HTML content to PDF format; this article illustrates how. The conversion consists of three steps: Convert the HTML to XHTMLConvert the XHTML document to XSL-FO (Extensible Stylesheet Language Formatting Objects) using an XSL stylesheet and an XSLT transformerPass the XSL-FO document to a formatter to generate the target PDF document Component versions The code in this article was tested with the following versions: Step 1: HTML to XHTML #/bin/sh <!