Jeremias Märki
Private Website

JAXG - Java API for XML Graphics processing


JAXG is an API and an abstraction layer for calling products which convert graphical XML dialects (like XSL-FO and SVG) to graphical output in various formats such as PDF, PostScript, Bitamp images etc. For example, it is supposed to simplify the integration of different XSL-FO implementations in one application as well as to reduce the learning curve involved with switching to a new tool. It borrows heavily from JAXP so developers familiar with JAXP won't have many problems using this API.

JAXG is open source and published under the Apache License version 2.0.

JAXG figure

Here's what a simple XSL+XSLT conversion to PDF would look like:

 //Set up the XGProcessor
 XGProcessorFactory factory = new SomeXGProcessorFactory();
 XGProcessorHandler xgHandler = factory.newXGProcessorHandler();
 //Set up the source, target and XSLT stylesheet      
 Source src = new StreamSource(new File("C:/temp/data.xml"));
 Source xslt = new StreamSource(new File("C:/temp/convert.xsl"));
 XGResult pdf = new StreamXGResult("application/pdf", 
         new File("C:/temp/out.pdf"));
 //Setup the JAXP Transformer      
 TransformerFactory tf = TransformerFactory.newInstance();
 Transformer transformer = tf.newTransformer(xslt);
 //This links the SAX output from the XSLT stage to the input of the XSL-FO stage
 Result res = new SAXResult(xgHandler);
 //Start the processing run
 transformer.transform(src, res);

Here is a list of currently available reference/demo implementations of the JAXG API:

  • Apache FOP 0.20.5 (XSL-FO to PDF, PS, PCL, Text and direct print)
  • Apache FOP Trunk/1.0dev (XSL-FO to PDF, PS, SVG, TIFF, PNG, RTF and direct print)
  • Apache Batik (SVG to PNG, JPEG, TIFF and PDF)
  • JFOR (XSL-FO to RTF)
  • FOray (XSL-FO to PDF, PS; PCL, SVG and Text)

JAXG is in its starting phase and if there is sufficient interest from the community this will go to a different location (maybe with a different name) as a stand-alone Open Source project. The current name "JAXG" may not be ideal since a Sun employee told me that there might be problems using the "JAX" prefix for something that doesn't come from Sun. If anybody has a good idea for a name, I'm all ears! I'm actually quite hesitant to rename the whole package yet again, as I already had to rename it from JAFOP to JAXG, because JAFOP had too much of "FOP" in the name and I don't want commercial adopters to be scared away because of that.

Please stay tuned! More info is coming up soon. In the meantime you can download the latest preview release from here. Javadocs are available, too.