Transformations API for XML - I

8 May 2008

In the next few posts, I will write about how to perform an XSLT transformation using StAX APIs: Cursor API and Event Iterator API.

TrAX (Transformations API for XML) is a Java API for performing XSLT transformations. In J2SE 1.5, there are three different ways to represent the source and the result of an XSLT transformation and they are: by XML stream source/result, by SAX events source/result, and by DOM tree source/result. In J2SE 1.6 an XSLT transformation is performed using a StAX (Streaming API for XML) source as an input and a StAX result as an output.

To get started, you should have Java 1.6 installed and working on your machine. Also you should have some knowledge of XSLT and StAX.

Lets start with XSLT/TrAX transformation process.

Firstly, we have to obtain a javax.xml.transform.TransformerFactory object. This class provides an XSLT processor. To obtain its object, we will instantiate this class by calling the newInstance method.

TransformerFactory transfFactory=TransformerFactory.newInstance();

We also have to set the javax.xml.transform.TransformerFactory system property:

//setting the javax.xml.transform.TransformerFactory system property for the Saxon processor 
System.setProperty("javax.xml.transform.TransformerFactory",
     "org.apache.xalan.processor.TransformerFactoryImpl");
//setting the javax.xml.transform.TransformerFactory system property for the Xalan processor 
System.setProperty("javax.xml.transform.TransformerFactory",
     "net.sf.saxon.TransformerFactoryImpl");

continued …

del.icio.us:Transformations API for XML - I  digg:Transformations API for XML - I  spurl:Transformations API for XML - I  wists:Transformations API for XML - I  simpy:Transformations API for XML - I  newsvine:Transformations API for XML - I  blinklist:Transformations API for XML - I  furl:Transformations API for XML - I  reddit:Transformations API for XML - I  fark:Transformations API for XML - I  blogmarks:Transformations API for XML - I  Y!:Transformations API for XML - I  smarking:Transformations API for XML - I  magnolia:Transformations API for XML - I  segnalo:Transformations API for XML - I  gifttagging:Transformations API for XML - I

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: Transformations API for XML - I

Leave a Reply