I suppose you mean something like this ...
<%@ page contentType="text/html"
import="net.sf.saxon.value.StringValue,
net.sf.saxon.trans.DynamicError,
net.sf.saxon.functions.SystemProperty,
net.sf.saxon.trans.DynamicError,
net.sf.saxon.FeatureKeys,
net.sf.saxon.Configuration,
net.sf.saxon.trace.XSLTTraceListener,
net.sf.saxon.TransformerFactoryImpl,
javax.xml.parsers.*,
org.w3c.dom.*,
javax.xml.transform.*,
javax.xml.transform.stream.*,
java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Title</title>
</head>
<body>
<%
System.setProperty("javax.xml.transform.TransformerFactory",
"net.sf.saxon.TransformerFactoryImpl");
StreamSource xml = new StreamSource(new File("c:/temp/hello.xml"));
StreamSource xsl = new StreamSource(new File("c:/temp/hello.xsl"));
StreamResult result = new StreamResult(out);
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(xsl);
transformer.transform(xml, result);
%>
</body>
</html>
and, great, it works ... but you are right I will try to develop some
custom saxon tag libraries, this will be more JSP minded.
Many thanks for your help.
Regards
Vincent
On Mon, September 4, 2006 13:46, Mukul Gandhi wrote:
You have written your code quite nicely to invoke XSLT transformation from
JSP.
You can further modularize it by creating a Java bean, or perhaps by
creating your custom JSP tags (as you have mentioned).
Please see my answers below.
On 9/4/06, Vincent Blondel <vincent@xxxxxxxxxxxx> wrote:
* How can this work without any jar file ( saxon.jar ) in my web
application, is this comimng from jdk ( 1.5.0_06 ) himself ?
No, Saxon jar file is not bundled with JDK 1.5.0_06. JDK comes bundled
with Xalan-J. If you want to use Saxon, you have to use it explicitly.
You have to place the Saxon jar in system classpath, and use it.
* How can I integrate my XSLT transformation with saxon exngine ?
To invoke Saxon via JAXP, you have to set the JAXP property
javax.xml.transform.TransformerFactory to
net.sf.saxon.TransformerFactoryImpl (for Saxon-b 8.7.3J)
* Is there a way to make this easier , with special Jsp Saxon tags ?
I am not quite sure. This is a Java application design issue. Perhaps
you can create your own JSP custom tags for invoking XSLT.
--
Regards,
Mukul Gandhi
http://gandhimukul.tripod.com