[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT Saxon Transformation in JSP pages ?

Subject: Re: XSLT Saxon Transformation in JSP pages ?
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Tue, 5 Sep 2006 22:38:08 +0530
jsp xsl tag
I meant this only.. Nice work.

On 9/5/06, Vincent Blondel <vincent@xxxxxxxxxxxx> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.