Friday, August 13, 2010

Instantiating XSLStylesheet object from XSL file.

As we know that ViewObjects can generate and consume XML using method like readXML(Element,int.XSLStylesheet) and writeXML(int,Long, XSLStylesheet). When dealing with XML and View Objects we could use stylesheets to control the format of the XML produced and consumed. In this post I provide an example how to get an instance of stylesheet file to that it can be consumed in ViewObject.

In order to get an instance of XSLStylesheet, create an stylesheet and add it to the project as resource. To do this go to project properties --> Project Source Paths --> Resource. Now add the XSL file to the include list. Doing so makes sure that file will be included when creating a war file for this application.




Now we can instantiate the an object of XSLStylesheet using this files as below:

No comments:

Post a Comment