Hello, so i tested what you advised me and it works. What i missed to tell you is that in my case the xsl files to launch are not directly on the disk but inside a jar or eventually in the jar of my java application.
Would you have an example of such scenario ?

thank you
Philippe




De :        Christophe Marchand <christophe.marchand@axyus.com>
A :        Mailing list for the SAXON XSLT and XQuery processor <saxon-help@lists.sourceforge.net>
Date :        18/10/2010 13:02
Objet :        Re: [saxon] example run saxon-b from java




I do aggree with you, Michael, regarding to performance  : DOM is not very efficient. But as a starter....

Regards,
Christophe

On 18/10/2010 12:08, Michael Kay wrote:

On 18/10/2010 10:50, Christophe Marchand wrote:
                TransformerFactory tFactory = new net.sf.saxon.TransformerFactoryImpl();
               Transformer t = tFactory.newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream("com/continental/corporation/yourXsl.xsl")));
               OutputStream out = new FileOutputStream(outputFile);
               t.transform(new DOMSource(yourDomStructure), new StreamResult(out));
               out.close();


This example supposed your XSL is in your sources, and then copied into your jar file.

Thanks for responding to this enquiry. But I wouldn't recommend using a DOMSource unless there is a very good reason: Saxon is much more efficient when you allow Saxon to build the source tree in its own format, rather than using a DOM.

So the example might become

               TransformerFactory tFactory = new net.sf.saxon.TransformerFactoryImpl();
               Transformer t = tFactory.newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream("com/continental/corporation/yourXsl.xsl")));
               OutputStream out = new FileOutputStream(outputFile);
               t.transform(new StreamSource(xmlInputURL), new StreamResult(out));
               out.close();


More generally, information about running XSLT from Java can be found at

http://www.saxonica.com/documentation/using-xsl/embedding.html

The example given by Cristophe uses the JAXP interface. You can find more examples of how to use JAXP in the sample program TraxExamples.java which is included in the saxon-resources download file (available on SourceForge as an optional download). This download also includes examples for the s9api API, which is the Saxon-specific transformation API.

Michael Kay
Saxonica



------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev


_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help