Re: [xsl] XSLT Saxon Transformation in JSP pages ?

Subject: Re: [xsl] XSLT Saxon Transformation in JSP pages ?
From: "Vincent Blondel" <vincent@xxxxxxxxxxxx>
Date: Tue, 5 Sep 2006 20:37:04 +0200 (CEST)
thanks a lot Rob, this is exactly what I was looking for. I will have a
look at the code to try to adapt it so I can use saxon engine.

Regards
Vincent.

On Tue, September 5, 2006 19:58, Robert Koberg wrote:
Hi,

You will probably want to create a Templates object to cache and create
you Transformer off of that. You will get better performance.

Also, before you write your own taglib, you might want to check out:

http://jakarta.apache.org/taglibs/doc/xsl-doc/intro.html

If you don't like it, at least you can use it as a starting point.

best,
-Rob


Vincent Blondel wrote:
> 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

Current Thread