Eclipse IDE provides a cool feature which allows you to execute XSL templates within the IDE. You just need to select the XSL file together with the XML file and choose from the context menu
Run As -> XSL Transformation
But for some reasons Eclipse is not supporting XSL 2.0 – which is standard in these days. So for example if you try to use xsl functions like ‘format-date-time’ or ‘replace’ this will not work. This is also true for Wilfly application server. So here is how to add XSLT 2.0 support for both – Eclipse and Wilffly
You can install an XSLT 2.0 processor manually into your Eclipse IDE:
- Download the latest Saxon XSLT processor
- Unzip the package to get the saxon9he.jar file and place it into your workspace or some external folder
- In eclipse choose “Window > Preferences” then “XML > XSL > Java Processors > Add”
- Fill in a “Processor Name”, e.g. “Saxon XSLT 2.0”
- In field “Processor type” choose “Saxon (XSLT 2.0)”
- Choose “Add external jar” and choose your saxon jar, e.g. “saxon9he.jar”
- Confirm by clicking “OK”
Now you can use saxon for XSLT 2.0 transformations in Eclipse. You need just configure your Run As Configurations and select the option ‘use specific process‘ to select the newly added Saxon processor.
Also wildfly server supports only XSL 1.0 per default. If you need XSL 2.0 in your application add the following maven dependency:
<!-- XSL 2.0 support--> <dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>9.8.0-14</version> </dependency>
2 Replies to “XSLT 2.0 with Eclipse and Wildfly”
Thanks for this tutorial. Could you please add some more details in the “Eclipse IDE” section especially regarding the Run Configuration settings? (I get a java.lang.ClassNotFoundException: org.xmlresolver.Resolver within main() from the Processor constructor (false) with Saxon HE-11)
– Which of the Eclipse IDEs should be used (only the Eclipse IDE for Enterprise Java and Web Developers provides the XML>XSL preference option that you describe)
– Should the project be a Java project or other e.g. Maven to run the examples provided by Saxonica?
– Where exactly is the option ‘use specific process‘ to be found?
– ….any other useful update since the time this tutorial was written.
Thanks in advance for your comments back.
The Eclipse Edition and also the Project type does not really matter here. A ClassNotFoundException indicates more that the Java Version used by Eclipse is not matching the required version of your xsl processor. The JRE can be defined in the run-configuration in the tab ‘JRE’. And you can define the XSL Processor in the run-configuration in the tab ‘Processor’.