Author: stevel
Date: Sat Dec 24 11:34:11 2005
New Revision: 358949
URL: http://svn.apache.org/viewcvs?rev=358949&view=rev
Log:
replace inline constants with strings, cleaner instantiation logic.
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
URL:
http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?rev=358949&r1=358948&r2=358949&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Sat
Dec 24 11:34:11 2005
@@ -160,6 +160,22 @@
private boolean useImplicitFileset = true;
/**
+ * The default processor is trax
+ * @since Ant 1.7
+ */
+ public static final String PROCESSOR_TRAX = "trax";
+ /**
+ * The xalan1 processor (deprecated option)
+ * @since Ant 1.7
+ */
+ public static final String PROCESSOR_XALAN1 = "xalan";
+ /**
+ * The xsl:p processor (deprecated option)
+ * @since Ant 1.7
+ */
+ public static final String PROCESSOR_XSLP = "xslp";
+
+ /**
* Creates a new XSLTProcess Task.
*/
public XSLTProcess() {
@@ -273,9 +289,9 @@
* the wrong version has been used.
*/
if (stylesheet.exists()) {
- log("DEPRECATED - the style attribute should be relative "
- + "to the project\'s");
- log(" basedir, not the tasks\'s basedir.");
+ log("DEPRECATED - the 'style' attribute should be relative
"
+ + "to the project's");
+ log(" basedir, not the tasks's basedir.");
}
}
@@ -314,9 +330,9 @@
}
}
} else { // only resource collections, there better be some
- if (resources.size() == 0) {
- throw new BuildException("no resources specified");
- }
+ if (resources.size() == 0) {
+ throw new BuildException("no resources specified");
+ }
}
processResources(stylesheet);
} finally {
@@ -453,28 +469,30 @@
* @exception Exception if the processor cannot be loaded.
*/
private void resolveProcessor(String proc) throws Exception {
- if (proc.equals("trax")) {
- final Class clazz = loadClass(TRAX_LIAISON_CLASS);
- liaison = (XSLTLiaison) clazz.newInstance();
- } else if (proc.equals("xslp")) {
+ String classname;
+ if (proc.equals(PROCESSOR_TRAX)) {
+ classname= TRAX_LIAISON_CLASS;
+ } else if (proc.equals(PROCESSOR_XSLP)) {
log("DEPRECATED - xslp processor is deprecated. Use trax "
+ "instead.");
- final Class clazz = loadClass(XSLP_LIAISON_CLASS);
- liaison = (XSLTLiaison) clazz.newInstance();
- } else if (proc.equals("xalan")) {
+ classname = XSLP_LIAISON_CLASS;
+ } else if (proc.equals(PROCESSOR_XALAN1)) {
log("DEPRECATED - xalan processor is deprecated. Use trax "
+ "instead.");
- final Class clazz = loadClass(XALAN_LIAISON_CLASS);
- liaison = (XSLTLiaison) clazz.newInstance();
+ classname = XALAN_LIAISON_CLASS;
} else {
- liaison = (XSLTLiaison) loadClass(proc).newInstance();
+ //anything else is a classname
+ classname = proc;
}
+ Class clazz = loadClass(classname);
+ liaison = (XSLTLiaison) clazz.newInstance();
}
/**
* Load named class either via the system classloader or a given
* custom classloader.
*
+ * As a side effect, the loader is set as the thread context classloader
* @param classname the name of the class to load.
* @return the requested class.
* @exception Exception if the class could not be loaded.
@@ -516,10 +534,10 @@
* @since Ant 1.7
*/
private void checkDest() {
- if (destDir == null) {
- String msg = "destdir attributes must be set!";
- throw new BuildException(msg);
- }
+ if (destDir == null) {
+ String msg = "destdir attributes must be set!";
+ throw new BuildException(msg);
+ }
}
/**
@@ -716,13 +734,13 @@
}
} else {
try {
- resolveProcessor("trax");
+ resolveProcessor(PROCESSOR_TRAX);
} catch (Throwable e1) {
try {
- resolveProcessor("xalan");
+ resolveProcessor(PROCESSOR_XALAN1);
} catch (Throwable e2) {
try {
- resolveProcessor("xslp");
+ resolveProcessor(PROCESSOR_XSLP);
} catch (Throwable e3) {
e3.printStackTrace();
e2.printStackTrace();
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]