Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Groovy's XML capabilities are powerful enough that you may not need to consider other alternatives such as XSLT. If you wish to use XSLT though, it isn't hard to do. Here we just added xalan and serializer jars from the Apache Xalan-J project to our CLASSPATH. Depending on your JVM version and other available libraries, you may need slightly different jars. Once our path is set up, we can run the following script to convert an XML file into XHTML:

Here is the output (pretty-printed):

Depending on your environment (JVM, XSLT processor, operating system) you might be able to make use of XSLT directly from the command line instead of calling it from Java or Groovy. You can also call it from Ant using the xslt task.

  • No labels