cancel
Showing results for 
Search instead for 
Did you mean: 

Execute XSL Template

parrym
Champ in-the-making
Champ in-the-making
After reading the JavaScript API Cookbook I learnt it is possible to execute a Freemarker template against a document using a webscript:

var result = document.processTemplate(template);
//where document is a document and template is a freemarker template.

I would like to do the same only with an XSL Template.

How do I execute an XSL template against a document using a webscript?
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
My first thought would be to check to see if E4X, the JavaScript XML library that's available from server-side Alfresco JavaScript, supports XSL transformations. Thinking it probably does not, I'd just use Java to create an Action that does it by leveraging your favorite XSLT processor. The beauty of an action is that you can call it from a rule, or from JavaScript, or from a workflow, or from Java code, or wherever. You can also give it parameters to control things like where the output of the transformation should be stored, etc.

A third option is to write the transformer as a service and then expose it to the JavaScript engine through Spring. Then, from JavaScript you could call your service, pass in the document and a pointer to your XSLT and get the transformation result back as a String. (If you also like the Action idea, you can have the Action invoke your service rather than perform the transformation in your action executer class directly).

Doing the transformation in Java gives you all kinds of options. Hopefully this gives you some ideas.

Jeff

parrym
Champ in-the-making
Champ in-the-making
Thank you for your reply. I will definitely take those options into consideration. I am also considering re-writing my XSL templates in Freemarker although there are quite a few…