It's outside this forum purpose, I contact you on private mail
Christophe

On 26/10/2010 15:31, Philippe.Favrais@continental-corporation.com wrote:
Thank you Christophe but when i do it, i get FilenotFoundException and it fails to compile the xsl

Philippe



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




new StreamSource(this.getClass().getClassLoader().getResourceAsStream("com/continental/corporation/yourXsl.xsl"))

in your jar :
/
/META-INF
/META-INF/MANIFEST.MF
/com
/com/continental
/com/continental/corporation
/com/continental/corporation/yourXsl.xsl

http://download.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)

Best regards,
Christophe


On 26/10/2010 14:59,
Philippe.Favrais@continental-corporation.com wrote:
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


------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev


_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev_______________________________________________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________ saxon-help mailing list archived at http://saxon.markmail.org/ saxon-help@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/saxon-help