xslt task loads extension classes from system classpath only (tested with xalan - xalan uses the context loader for loading extension classes).

I think, it will be a good idea that the classpath for extension classes can be configured in the ant script.

This patch sets the context loader used for loading the processor and resets it after processing.
So an extension class will be loaded from classpath specified in the classpath attribute of the xslt task.


Tested with Xalan/JDK1.4.2 and docbook extensions for xalan. Don't know how other processors are loading extension classes. There are disadvantages setting the context loader for processing?


There is another issue that can be solved in this way: switching xalan versions for jdk1.4 is crucial. It can be done setting endorsed.dirs while starting the jvm only.
Setting the AntClassLoader in isolated mode and specifying needed classes in classpath attribute of xslt task can solve this issue (not tested).



Claas -- ____________________________________________________________________ Dipl.-Inf. Claas Thiele EMail: [EMAIL PROTECTED] Konradstr. 58 Web: http://ct42.de 04315 Leipzig Tel.: +49 (0)341 68 70 92 29 GERMANY Fax +49 (0)341 68 70 92 30

--- 
/usr/local/devres/ANT/apache-ant-1.6.0/src/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  2003-12-18 21:16:12.000000000 +0100
+++ XSLTProcess.java    2004-01-29 21:09:53.000000000 +0100
@@ -164,6 +164,11 @@
     private boolean reuseLoadedStylesheet = true;
 
     /**
+     * classloader for liaison
+     */
+    private AntClassLoader classloader = null;
+    
+    /**
      * Creates a new XSLTProcess Task.
      */
     public XSLTProcess() {
@@ -218,6 +223,9 @@
                 baseDir = getProject().resolveFile(".");
             }
 
+            classloader = getProject().createClassLoader(classpath);
+            classloader.setThreadContextLoader();
+            
             liaison = getLiaison();
 
             // check if liaison wants to log errors using us as logger
@@ -279,6 +287,7 @@
             liaison = null;
             stylesheetLoaded = false;
             baseDir = savedBaseDir;
+            classloader.resetThreadContextLoader();
         }
     }
 
@@ -422,8 +431,7 @@
         if (classpath == null) {
             return Class.forName(classname);
         } else {
-            AntClassLoader al = getProject().createClassLoader(classpath);
-            Class c = Class.forName(classname, true, al);
+            Class c = Class.forName(classname, true, classloader);
             return c;
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to