Hi, Raj.

Rajesh Jain <[EMAIL PROTECTED]> wrote on 2008-04-22 11:08:22 AM:
> ava org.apache.xalan.xsltc.cmdline.Compile -j
> D:\tomcat\webapps\centauri\translets.jar -p com.centauri.xsltc -x 
> D:\tomcat\webapps\centauri\index.xsl
> 
> and I can get the translets.jar file
> 
> My question is how do I use the translets.jar file in tomcat, where my
> web-architecture renders XML Streamed documents using the XSL 
stylesheets.
> Can I replace the Stylesheet XSL files with the Java Classes and the
> Transformer should pickup the Java classes rather than the XSL 
stylesheets?
> 
> I know it is kind of tied to my product architecture, but just wanted to 
get
> your thoughts if there is a easy way to some kind of Smart 
transformations. 

You should be able to include the translets.jar as part of your 
application.  In your application, call the setAttribute method on your 
TransformerFactory to specify that you want to load the precompiled 
stylesheet from your class path along with the package name.  (See [1] for 
the definitions of these attributes.)  For example:

TransformerFactory tf = TransformerFactory.newInstance();
try {
    tf.setAttribute("package-name", "com.centauri.xsltc");
    tf.setAttribute("use-classpath", Boolean.TRUE);
} catch (IllegalArgumentException iae) {
    // Couldn't set the attributes - let's see what happens
}
Transformer t = tf.newTransformer(new StreamSource("index.xsl"));

I hope that helps.

Thanks,

Henry
[1] http://xml.apache.org/xalan-j/xsltc_usage.html#api-attributes
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab   T/L 313-6044;  Phone +1 905 413-6044
mailto:[EMAIL PROTECTED]

Reply via email to