Appendix D: JAXP: The Java API for Transformation


Overview

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. The same program can be used to execute transformations using Saxon, Xalan, Oracle, or jd.xslt. This 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')"/>   on <xsl:value-of select="current-date()"/>   </xsl:comment>  

The current version is JAXP 1.2, though a version 1.3 is under development for inclusion in JDK 1.5. It doesn't look as if there will be major changes affecting the transformation part of JAXP in the new version, just some tightening up of the specifications in areas that have proved unclear. In particular, the new version does not yet support XSLT 2.0. The most important extensions in JAXP 1.3 are that it supports direct use of XPath, and also schema processing (not just using XML Schema as defined by W3C, but using any schema language, for example Relax NG).

In fact, very few changes to JAXP are needed for XSLT 2.0. When such an upgrade comes, the main extensions are likely to be:

  • A mechanism for starting the transformation with no source document, and/or by specifying an initial template

  • The ability to specify an initial mode in which the transformation should start

  • A definition of how stylesheet parameters of different types should be passed to the setParameter() method

  • Several new constants to define parameters for output serialization

A useful source for information about JAXP is the unofficial JAXP FAQ published by Edwin Goei at http://xml.apache.org/~edwingo/jaxp-faq.html .




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net