You can use Saxon via the JAXP API. All you need to do is to ensure that Saxon gets invoked as the XSLT processor. There are various ways you can achieve this:
 
(a) in theory, it's enough to have saxon8.jar on the classpath. However, this is a bit fragile, and also causes a search of the classpath, which can be slow.
 
(b) you can set the system property javax.xml.transform.TransformerFactory to the string "net.sf.saxon.TransformerFactory" (or for Saxon-SA, "com.saxonica.SchemaAwareTransformerFactory"). You can do this either from the command line using the -D switch (this is a java option, so it goes before the class name: "java -Djavax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactory net.sf.saxon.Transform ..."), or you can do it by calling System.setProperty() before you call TransformerFactory.newInstance().
 
(c) You can instantiate Saxon directly by calling "new net.sf.saxon.TransformerFactory()" in place of "TransformerFactory.newInstance()". This is the fastest and most reliable method; its only disadvantage is that your code then has a compile-time reference to Saxon.
 
Another tip: include
 
<xsl:comment><xsl:value-of select="system-property('xsl:vendor')"/></xsl:comment>
 
in your stylesheet so that you can see which XSLT processor was actually used.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-bounces@lists.sourceforge.net [mailto:saxon-help-bounces@lists.sourceforge.net] On Behalf Of naveen kumar
Sent: 20 August 2007 11:23
To: saxon-help@lists.sourceforge.net
Subject: [saxon] applying stylesheet to xml

hi,

i am very new to saxon and i am very familiar with JAXP. but being a beginner in saxon i am unbale to know
how to apply xslt to xml using saxon-java api.not using command line type.i exhaustly searched gogole but no
result. any help in this regard is great helpful.