Appendix E. JAXP: The Java API for Transformation

JAXP is a Java API for controlling various aspects of XML processing, including parsing, validation, and XSLT transformation. This appendix concentrates on the transformation API. During its development this was known as TrAX (Transformation API for XML) — you will still see this term used occasionally.

JAXP is well supported by all the Java XML processors. The benefit of JAXP is that it allows you to write Java applications that invoke XSLT transformations without committing your application to a particular XSLT processor. At one time, there were five different Java processors you could choose from (xt, Saxon, Xalan, Oracle, or jd.xslt) but for most people now the choice has whittled down to Xalan and Saxon (though both these products have a choice of processors within the same product family). JAXP works so well that I have come across users who were running Saxon when they thought they were using Xalan, or vice versa. It's a good idea to include the following instruction in your initial template so that you avoid this mistake:

<xsl:comment>
   Created using <xsl:value-of select="system-property("xsl:vendor')'/>
</xsl:comment>

The version numbers for JAXP are irritatingly out of sync with those of the JDK. The following table shows the correspondence:

JAXP version

JDK version

New Functionality

1.2

JDK 1.4

XML Parsing (SAX and DOM) and Transformation

1.3

JDK 1.5 (Java 5)

Schema processing; XPath processing; DOM level 3

1.4

JDK 1.6 (Java 6)

Pull parsing ...

Get XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.