XSLT processing in Java - I

17 April 2008

XSLT (Extensible Stylesheet Language Transformations) is used to transform XML files into other formats like HTML format. There are many XSLT processors (libraries) available to be used in Java for XSLT transformation. These libraries can be used from a Java application like JSP/Servlet to read a XML file and to transform it into a HTML.

An XSLT processor takes two inputs: an XML file and an XSLT stylesheet.

For this post, I have chosen Xalan-Java library for the transformation.

Xalan-Java is an XSLT processor for transforming XML documents into HTML, text, or other XML document types. It implements XSL Transformations (XSLT) Version 1.0 and XML Path Language (XPath) Version 1.0 and can be used from the command line, in an applet or a servlet, or as a module in other program.

Source: http://xml.apache.org/xalan-j/

To use Xalan-Java, we have to include its JAR file in the class path so we can invoke the appropriate methods. You may download the required JARs from:

http://xml.apache.org/xalan-j/downloads.html

Now lets take an example. We have following XML file:

<?xml version="1.0" encoding="UTF-8"?>
<message>Yep, it worked!</message>

continued …

del.icio.us:XSLT processing in Java - I  digg:XSLT processing in Java - I  spurl:XSLT processing in Java - I  wists:XSLT processing in Java - I  simpy:XSLT processing in Java - I  newsvine:XSLT processing in Java - I  blinklist:XSLT processing in Java - I  furl:XSLT processing in Java - I  reddit:XSLT processing in Java - I  fark:XSLT processing in Java - I  blogmarks:XSLT processing in Java - I  Y!:XSLT processing in Java - I  smarking:XSLT processing in Java - I  magnolia:XSLT processing in Java - I  segnalo:XSLT processing in Java - I  gifttagging:XSLT processing in Java - 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: XSLT processing in Java - I

Leave a Reply