ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trevor Harmon <tre...@vocaro.com>
Subject Re: Custom processor for Xslt task?
Date Wed, 03 Jan 2007 05:15:58 GMT
On Jan 2, 2007, at 7:58 AM, Dominique Devienne wrote:

> On 12/30/06, Trevor Harmon <trevor@vocaro.com> wrote:
>> I'm trying to use Saxon instead of the built-in Xalan processor for
>> the Xslt task. Supposedly, all I have to do is specify a classpath
>> when calling the task [1], but I've never been able to get this to
>> work. Ant always finds the built-in processor in its lib directory.
>
> Using the excellent Saxon XSLT processor with Ant is discussed in  
> Ant Wiki.

There's a bug on that page: ${antHome} should be ${ant.home}. But  
it's not necessary to specify ant-trax.jar in the classpath anyway.

> To answer Jay, Ant uses the JDK-provided TraX API to locate an XSLT
> processor, which obeys the discovery rules prescribed by TraX. In
> short, if Saxon is first in the classpath, it should be the processor
> picked up by default.

This is exactly what was causing my problem. Turns out xalan-j was  
already on my CLASSPATH environment variable, so Ant was always  
finding it first, no matter what I specified in the classpath  
attribute of Xslt. Ugh...classpath hell...

Unfortunately, it's not so easy to fix this because I use Fink, and  
its ant-optional package, which is required for any of Ant's optional  
tasks, depends on xalan-j.

> Using an explicit factory overrides this default behavior. --DD

Okay, that should fix my Fink problem, except I can't get it to work.  
I've created a test case that's just like the Ant Wiki code, except  
I've specified net.sf.saxon.TransformerFactoryImpl in the <factory>  
element. But when I do that, I always get  
java.lang.ClassNotFoundException. I can work around it by explicitly  
putting Saxon's JAR in the -lib command-line parameter, or in my  
CLASSPATH environment variable, but then that defeats the whole point  
of a factory override.

Here's the test case:

http://vocaro.com/trevor/files/saxon-test.zip

How do I get the override behavior you describe, instead of a  
ClassNotFoundException? I'm using Ant 1.7.0. Thanks,

Trevor


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message