My favorites | Sign in
Project Home Downloads Wiki Issues Source
Project Information
Members
Links

Introduction

jxsl goals are :

  • to provide a very simple API to run XSL transformation from Java code, on top of JAXP;
  • to foster the adoption of XSL Unit testing and integration into Continuous Integration processes, on top of XSpec.

Simple API to run XSLT from Java code

Applying an XSL on XML content might be as simple as

// Create a transformation scenario
XslScenario sc = new XslScenario("path_to_your_xsl.xsl");

// Run this scenario on XML content
 Map<String, String> outputs = sc.apply("xml_content");

// Display transformation result
System.out.println(outputs.get(XslScenario.MAIN_OUTPUT_KEY));

where:

  • "path_to_your_xsl.xsl" can be a File, URL or String
  • "xml_content" can be byte[], File or String

XslScenario object lets you easily manage XSL parameters and multiple outputs. See XslScenario page for more information.

XSL Unit testing

Once you have written XSpec test scenarios, jxsl allows you to quickly integrate them into your build or continous integration processes.

jxsl comes with a Maven archetype to help you start quickly. Ant support is coming soon. To make it short:

  1. First, you need to install Maven and have Saxon 9.3.0.2j library deployed in your local Maven repository.
  2. Generate the archetype with the following code
  3. mvn archetype:generate -DarchetypeGroupId=com.servicelibre -DarchetypeArtifactId=xspec-test -DarchetypeVersion=0.1.11 -DarchetypeCatalog=http://jxsl.googlecode.com/svn/trunk/archetypes
  4. Test your new XSL test project.
  5. mvn test
  6. Specify the location of your XSpec files by editing src/test/resources/xspec-context.xml
  7. Run your own tests
  8. mvn test
  9. Add your new project to your source control system (Subversion, Git, Mercurial, etc.) and link it to your Continuous Integration server (Hudson, TeamCity, CruiseControl, Mike, etc. )

For detailed setup instructions, read XslUnitTesting page.

Happy XSL testing!

Powered by Google Project Hosting