48 The XML Files: Develo pment of XML/XSL A pplications Using WebS phere Studio
Figure 2-2 The XSLT compiler
The Apache XML project ( xml.apache.org) provides XSLTC, which is a compiler
and runtime processor. The compiler can be used to compile an XSL stylesheet
into a set of Java classes called translets. The classes than can be deployed, just
like any other Java classes, along with the xsltc.jar and the runtime.jar. The
compiler and the translets can be run from the command line, and also the
TrAX/JAXP API. TrAX provides a framework and a standard API for performing
XML transformation, and it uses systems properties to locate the Transformer
and the XML parser.
The JAXP API can be found in the Java XML Pack, which can be downloaded
from the Sun Web site. Besides the two methods, the XSLTC can also be used
with the native Java API.
Xalan-Java Version 2 is an XSLT processor built upon on SAX 2 and DOM 2. It
implements the W3C recommendations for XSLT and the XMl Path language
(XPath). It can be used from the command line, in a Java class (applet or
servlet), or as a module in another program.
For more details, visit
Using XSLTC:The Apache XML Project
at:
http://xml.apache.org/xalan-j/xsltc_usage.html
Xalan-Java version 2.4.D1: The Apache XML project at:
http://xml.apache.org/xalan-j/index.html
translet running
on JVM
<xsl:template match="Customer">
<h1>Input XML Form </h1>
<form action="/Travel/CustomerXSLServlet" method="post">
<table border="0" cellpadding="2" cellspacing="0">
<xsl:apply-templates select="firstname"/>
</table>
</form>
</xsl:template>
XML input
file
Output
XML,
HTML, etc
XSLT
stylesheet
Compiler
JVM
bytecode transA.class