Trax & Translets: use-classpath 2003-09-17 - By Morris Kwan
If the use-classpath attribute is set, the input is not read from the Source argument to newTransformer(). It relies on the class loader to load the class instead. You can write a custom class loader to load the translet from a database. Otherwise there is no clean solution which satisfies your requirement. If you don't use the custom class loader, there is another ugly solution though. You can read the translet bytecode into a byte array, then define a Translate class from the bytecode array. After that you need to use the XSLTC native API to do the transformation. Please look at the code in org.apache.xalan.xsltc.compiler.cmdline.Transform on how this can be done. If you use this, remember that using the native API is not a recommended solution. The native API might change in the future without a notice.
Regards,
Morris Kwan XSLT Development IBM Toronto Lab Tel: (905)413-3729 Email: mkwan@(protected)
Eric_Powers@(protected) tput.com To: xalan-j-users@(protected) .apache.org cc: 09/17/2003 12:59 Subject: Trax & Translets: use -classpath PM
From the XSLTC command line doc (Xalan 2.5.1):
If the use-classpath attribute is set to true, the translet will be loaded
from the CLASSPATH. This attribute is typically used in a case when the
translets are packaged in a prebuilt jar file which is included in the
CLASSPATH.
All the Trax/translet examples show this code:
String transletURI = args[1];
TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute("use-classpath", Boolean.TRUE);
Transformer transformer = tf.newTransformer(new StreamSource(transletURI));
I intend to store the translet in a database and would like to use an
InputStream to create the transformer:
tf.setAttribute("use-classpath", Boolean.FALSE);
Transformer transformer = tf.newTransformer(new StreamSource(dbInputStream));
It doesn't appear that translets can be loaded without using the file system and use-classpath attribute.
I would like to avoid writing the translet from the database to a temporary location on the file system to load the translet. Is there any way to do
this?
Thanks,
Eric
|
|