You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Morris Kwan <mk...@ca.ibm.com> on 2003/12/01 16:44:46 UTC
Re: Apache Xalan-J XSLTC: how to set for on-demand XSL compilation
Hi, Gaurav
You can set the "auto-translet" attribute to true. If "auto-translet" is
set to true, the TransformerFactory will create a Templates object from the
existing translet if the translet exists and its time stamp is newer than
the .xsl file, otherwise it will generate a new translet from the
stylesheet. The "auto-translet" and "generate-translet" options should not
be used with the "use-classpath" option. If they are used together,
"use-classpath" will take precedence.
Regards,
Morris Kwan
XSLT Development
IBM Toronto Lab
Tel: (905)413-3729
Email: mkwan@ca.ibm.com
Gaurav
<Gaurav.Gandhi@Su
n.COM> To
xalan-j-users@xml.apache.org
11/28/2003 02:34 cc
PM
Subject
Apache Xalan-J XSLTC: how to set
Please respond to for on-demand XSL compilation
Gaurav.Gandhi
Summary:
I am trying to use Xalan-J's compilation based TransformerFactory to
create "Translets" on the fly. But dont know how to do that.
(http://xml.apache.org/xalan-j/xsltc_usage.html)
Details:
I set the concerned system property to point to Xalans compilation based
Transformer
Properties props = System.getProperties();
props.put("javax.xml.transform.TransformerFactory",
"org.apache.xalan.xsltc.trax.TransformerFactoryImpl");
and then set a couple of attributes as follows:
transformerFactory.setAttribute("translet-name", convId);
transformerFactory.setAttribute("destination-directory",
"/uwc_base/dist/JDK1.4_DBG.OBJ/WEB-INF/lib");
transformerFactory.setAttribute("package-name", "com.blah.translets");
transformerFactory.setAttribute("jar-name", "iabs-translets.jar");
transformerFactory.setAttribute("generate-translet", Boolean.TRUE);
transformerFactory.setAttribute("use-classpath", Boolean.TRUE);
....
_templates = transformerFactory.newTemplates(new DOMSource(xslDoc));
Now, the "use-class" property = true, indicates that the the
TransformerFactorty should expect a precompiled Translet (Java Class
representation of XSL) at the ClassPath.
For this I will have to make sure that the translet is generated before
the application starts.
If "use-class" property = false, the TransformerFactory will compile the
XSL into translet on its own.
I would like a way where XSLTranformerFactory determines on its own
whether a Translet is already existing. If yes, it shoud use it, and if
no it should generate it.
Is there a way that can be done by setting some attribute of the
factory, and without me having to write code to check the presence of
the translet?
I read from somewhere that setting the attribute "use-from-classpath" to
true, accomplishes that, but looks like the XSLTC factory does not
support that attribute.
Thanks in advance,
Gaurav