Hi Tamurg,

The quickest way to prove you are using the compiled transformation would be
to remove the stylesheets from the classpath of the application at runtime.
You would get a error if the application is trying to locate the
stylesheets.  Alternatively introduce a measurable difference between the
compiled and raw stylesheet.
How are you embedding fop in your application?  Are you following the
documentation at
http://xmlgraphics.apache.org/fop/trunk/embedding.html#render-with-xslt ?
This may help too -
http://xmlgraphics.apache.org/fop/trunk/running.html#check-input

Pete



On Thu, Jan 28, 2010 at 10:27 PM, tamugrg <[email protected]>wrote:

>
> Hi,
> I am trying to use Apache FOP translets which would hopefully improve my
> performance than creating new transfomer (even for the first time). I could
> not find an example of using Apache FOP translets. I am not sure whether my
> code uses translets or not. Would anyone know whether I am doing it the
> correct way in terms of compiling & using the translets &  also whether
> there is anyway that I can verify that even for the first time the xsl's
> are
> being used in the application (after server startup), it is using the
> compiled translets (from the jar file that i have put in my maven
> repository
> p1.p2.myTranslet.jar) AND not compiling the xsl's into templates again.
> Below lists what I have done.
>
> Translet Compiling
> ============
> => SET CLASSPATH=xalan-2.7.1.jar;xml-apis-1.3.04.jar;xercesIm
> pl-2.9.1.jar;serializer-2.7.1.jar
> => ava org.apache.xalan.xsltc.cmdline.Compile -p p1.p2 -x -j myTranslet.jar
> stylesheet1.xsl stylesheet2.jar
>
> Using the translets
> ============
>
> // Static part of the class has a section that creates the templates from
> all our xsl's & puts it in HashMap 'templatesStore'
>
>            for (String label_xsl : LABEL_XSL_RESOURCES)
>            {
>                Source source = classpathSource(label_xsl);
>                templatesStore.put(label_xsl,
> trasformerFactory.newTemplates(source));
>            }
>
>
> Using Translets
> ==========
>        trasformerFactory = TransformerFactory.newInstance();
>        trasformerFactory.setURIResolver(new
> ClassUriResolver(LABEL_XSL_RESOURCE_PATH));
>
>
>        // For using the translets
>        // Set the TransformerFactory system property.
>        // Note: For more flexibility, load properties from a properties
> file.
>        trasformerFactory.setAttribute("debug", Boolean.TRUE);
> //        trasformerFactory.setAttribute("use-classpath", Boolean.TRUE);
>        trasformerFactory.setAttribute("package-name", "p1.p2");
>        trasformerFactory.setAttribute("jar-name", "myTranslet");
>        trasformerFactory.setAttribute("translet-name", "myTranslet");
>
>        String key = "javax.xml.transform.TransformerFactory";
>        String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
>        Properties props = System.getProperties();
>        props.put(key, value);
>        System.setProperties(props);
>
>
> // Using the translets
>    Templates templates = (Templates) templatesStore.get(xsltResourceName);
>        if (templates != null) {
>            return templates.newTransformer();
>        }
>        else
>        {
>            throw new TransformerException("Could not create a new
> Transformer for " + xsltResourceName + "; Template not found.");
>        }
> --
> View this message in context:
> http://old.nabble.com/Using-Apache-FOP-translets-in-java-EE-application-tp27364146p27364146.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to