Glenn,
We are just after finishing an initial implementation of the entire TrAX API
for XSLTC. We decided to separate the TrAX implementation and the native
XSLTC APIs, and this is why the AbstractTranslet class no longer implements
the Transformer interface. All TrAX code is located in the
org.apache.xalan.xsltc.trax
package. This is becuase many of our current users choose to use XSLTC's
native API, and we don't want these to have to include all the extra code
for TrAX in their applets/servlets/JSPs what have you.
But please not that we are in the phase of testing/bugfixing our TrAX code,
and that it is not yet stable code.
I will look into the System.exit() call and have it removed from the code.
Thank you for your interest in XSLTC,
Morten J�rgensen
Glenn Nielsen wrote:
>
> I am implementing precompiled XSLTC Translets in a Servlet using Xalan 2.1.
>
> I created my own class with implements the Templates interface so that
> the Servlet can instantiate the stylesheet from file if it exists or
> instantiate it from a precompile Translet class. i.e. If the xsl file exists
> it is used, if not the translet is used.
>
> Here is the code for my Templates implementation:
>
> ----------------------------------------------------------------------------
> package net.more.servlets.soapschema;
>
> import javax.xml.transform.Templates;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerConfigurationException;
> import javax.xml.transform.sax.SAXTransformerFactory;
>
> import org.apache.xalan.xsltc.runtime.AbstractTranslet;
> import java.util.Properties;
>
> /**
> * Implementation of a JAXP1.1 Templates object for Translets.
> */
> public class SchemaTransletTemplate implements Templates {
> private Class _translet = null;
>
> public SchemaTransletTemplate(Class clazz) {
> _translet = clazz;
> }
>
> public Properties getOutputProperties() { /*TBD*/ return null; }
>
> public Transformer newTransformer() throws
> TransformerConfigurationException
> {
> if (_translet == null) {
> throw new TransformerConfigurationException(
> "Error: Null Translet");
> }
> Transformer trans = null;
> try {
> trans = (Transformer)_translet.newInstance();
> } catch(Exception e) {
> throw new TransformerConfigurationException(
> "Error: Could not instantiate Translet: " + e.toString());
> }
> return trans;
> }
> }
> ----------------------------------------------------------------------------
>
> Here is the code which does the transformation using either a template
> instantiated from an XSL file or from a precompiled translet.
>
> ----------------------------------------------------------------------------
> private void transformResponse(Templates xslt, StringReader data,
> Writer out) throws ServletException {
> StreamSource source = new StreamSource(data);
> StreamResult result = new StreamResult(out);
> try {
> Transformer transformer = xslt.newTransformer();
> transformer.transform(source,result);
> } catch(TransformerConfigurationException e) {
> throw new ServletException("XSL Transformation" +
> " location: " + e.getLocationAsString() +
> " failure: " + e.getMessageAndLocation());
> } catch(Exception e) {
> throw new ServletException("XSL Transformation failed",e);
> }
> }
> ----------------------------------------------------------------------------
>
> The above works for a template created at runtime from an XSL stylesheet
> but fails for the Translet. What is really annoying is that when the
> Translet fails it calls System.exit(). This is not considerate behaviour
> when the Translet is running inside a servlet container.
>
> Fortunately I run Tomcat 4 with the Java SecurityManager enabled so that
> the attempt to use System.exit() caused a SecurityException instead of
> terminating Tomcat.
>
> I still don't know whether there is some failure causing the Translet to
> call System.exit() or it just does it.
>
> I have tried to use this code with the 2.2D8 Xalan release, but there
> seem to be some changes to the API for Translets where they no longer
> implement the Transformer interface.
>
> Regards,
>
> Glenn
>
> ----------------------------------------------------------------------
> Glenn Nielsen [EMAIL PROTECTED] | /* Spelin donut madder |
> MOREnet System Programming | * if iz ina coment. |
> Missouri Research and Education Network | */ |
> ----------------------------------------------------------------------
--
E-mail: [EMAIL PROTECTED]
Phone: +353 1 819 9071 / x-19071
--8<-----------------------------------------------------------
C'est l'histoire d'un mec qui tombe d'un immeuble de cinquante
�tages. A chaque �tage, a fur et � mesure de sa chute, il se r�p�te
sans cesse pour se rassurer:
Jusqu'ici tout va bien,
jusqu'ici tout va bien,
jusqu'ici tout va bien...
Mais l'important, c'est pas la chute, c'est l'atterrissage.