Merge all XSL files
I am using XSL/JSP to design the Application Form.
Now I want to split header, sidebar, footer and
app form into 4 XSL files, only app form will receive dynamic data from XML, the rest are static pages.
One way I can think of is using 5 JSPs to process
E.g.
ApplicationForm.jsp
->Header.jsp-> Header.xsl
->sidebar.jsp-> Sidebar.xsl
->Footer.jsp-> Footer.xsl
->Form.jsp-> Form.xsl
But this method may be very expensive as each JSP has to invokes XSLTProcessor.process()
How can I process these XSL files better in term of performance?
Can I merge all XSL files into one first?
Albert KT Tan
[714 byte] By [
kttan] at [2007-9-26 1:55:49]

I am working on a project currently where I am faced with a similar decision. I have created a java class that takes two input strings (another method takes in two Files) one is the xml doc and the other the xsl. It transforms the xml and returns valid html.
So my base JSP looks like:
<html>
<body>
<!-- the header -->
<% out.println(MyClass.applyXML(xmlString, xslString)); %>
Here's some static content
<% out.println(MyClass.applyXML(xmlString2, xslString2)); %>
</body>
</html>
It's really fairly fast this way even though I'm doing several transformations.
Hope this helps,
Let me know if you have any more questions,
-Mike
Thanks Mike!
What I am looking for is something like include directive in JSP, which can insert other files into current JSP.
I am wondering if XSL has the similar function to include other XSL files into current XSL.
This way I don't have to bother the presentation/layout in my JSP code, except calling the main XSL file.
Do I miss out something here?...
Albert
kttan at 2007-6-29 3:10:16 >

Hello,
I'm not exactly sure I get what you're looking for.
What I was suggesting was one jsp calling a Java Class 5 times and outputting the XML string translated to HTML in their proper places.
You're going to have 5 input xml files, so no matter what you're going to have to do 5 translations, right? If so what's the difference if you pass the same xsl to each translation or 5 different ones? Is this the part I'm confused on?
You could do it like this too.
<%
//The class that does the translations
ApplyXML ax = new ApplyXML();
String header = ax.apply(xmlFilePathHeader, xslFilePathHeader);
String sidebar = ax.apply(xmlFilePathSidebar, xslFilePathSidebar);
String footer = ax.apply(xmlFilePathFooter, xslFilePathFooter);
String form = ax.apply(xmlFilePathForm, xslFilePathForm);
%>
<!-- then just plug the translated strings in where you need them. -->
<html>
<body>
<table>
<tr>
<td colspan="2">
<% out.println(header); %>
</td>
</tr>
<tr>
<td>
<% out.println(sidebar); %>
</td>
<td>
<% out.println(form); %>
</td>
</tr>
<tr>
<td>
<% out.println(footer); %>
</td>
</tr>
</table>
</body>
</html>
Am I still misunderstanding?
-Mike