bodewig 01/03/13 06:15:22
Modified: . WHATSNEW
docs/manual/CoreTasks style.html
src/main/org/apache/tools/ant Project.java
src/main/org/apache/tools/ant/taskdefs XSLTProcess.java
Log:
revert <style> to old behavior - make its style attribute interpreted
as relative to the basdir attribute. Make sure it works when handed an
absolute path.
Revision Changes Path
1.85 +2 -3 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -r1.84 -r1.85
--- WHATSNEW 2001/03/12 14:47:44 1.84
+++ WHATSNEW 2001/03/13 14:15:20 1.85
@@ -6,9 +6,6 @@
* Zip.setWhenempty() has changed its signature.
-* <style>'s style attribute will be resolved as relative to the
- projects basedir instead of the basedir attribute of the task.
-
Fixed bugs:
-----------
@@ -26,6 +23,8 @@
and omit tasks it fails to load.
* won't try to pass a -bootclasspath flag to javac 1.1 anymore
+
+* <style>'s style attribute no handles absolute paths correctly.
Changes from Ant 1.2 to Ant 1.3
===========================================
1.4 +2 -1 jakarta-ant/docs/manual/CoreTasks/style.html
Index: style.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTasks/style.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- style.html 2001/03/09 08:54:35 1.3
+++ style.html 2001/03/13 14:15:20 1.4
@@ -52,7 +52,8 @@
</tr>
<tr>
<td valign="top">style</td>
- <td valign="top">name of the stylesheet to use.</td>
+ <td valign="top">name of the stylesheet to use - given either relative
+ to the basedir attribute or as an absolute path.</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>
1.55 +13 -3 jakarta-ant/src/main/org/apache/tools/ant/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- Project.java 2001/03/12 14:04:15 1.54
+++ Project.java 2001/03/13 14:15:21 1.55
@@ -537,7 +537,13 @@
} while (!curtarget.getName().equals(targetName));
}
- public File resolveFile(String fileName) {
+ /**
+ * Return the canonical form of fileName as an absolute path.
+ *
+ * <p>If fileName is a relative file name, resolve it relative to
+ * rootDir.</p>
+ */
+ public File resolveFile(String fileName, File rootDir) {
fileName = fileName.replace('/', File.separatorChar).replace('\\',
File.separatorChar);
// deal with absolute files
@@ -580,14 +586,14 @@
return new File(sb.toString());
}
- File file = new File(baseDir.getAbsolutePath());
+ File file = new File(rootDir.getAbsolutePath());
StringTokenizer tok = new StringTokenizer(fileName, File.separator,
false);
while (tok.hasMoreTokens()) {
String part = tok.nextToken();
if (part.equals("..")) {
String parentFile = file.getParent();
if (parentFile == null) {
- throw new BuildException("The file or path you specified
(" + fileName + ") is invalid releative to " + baseDir.getAbsolutePath());
+ throw new BuildException("The file or path you specified
(" + fileName + ") is invalid releative to " + rootDir.getAbsolutePath());
}
file = new File(parentFile);
} else if (part.equals(".")) {
@@ -605,6 +611,10 @@
e.getMessage(), MSG_ERR);
return new File(file.getAbsolutePath());
}
+ }
+
+ public File resolveFile(String fileName) {
+ return resolveFile(fileName, baseDir);
}
/**
1.17 +9 -10
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
Index: XSLTProcess.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XSLTProcess.java 2001/03/12 11:24:22 1.16
+++ XSLTProcess.java 2001/03/13 14:15:22 1.17
@@ -84,7 +84,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Keith Visco</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sam Ruby</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Russell Gold</a>
- * @version $Revision: 1.16 $ $Date: 2001/03/12 11:24:22 $
+ * @version $Revision: 1.17 $ $Date: 2001/03/13 14:15:22 $
*/
public class XSLTProcess extends MatchingTask {
@@ -92,7 +92,7 @@
private File baseDir = null;
- private File xslFile = null;
+ private String xslFile = null;
private String targetExtension = ".html";
private Vector params = new Vector();
@@ -153,10 +153,11 @@
long styleSheetLastModified = 0;
if (xslFile != null) {
try {
+ File file = project.resolveFile(xslFile, baseDir);
// Create a new XSL processor with the specified stylesheet
- styleSheetLastModified = xslFile.lastModified();
- log( "Loading stylesheet " + xslFile, Project.MSG_INFO);
- liaison.setStylesheet( xslFile.toString() );
+ styleSheetLastModified = file.lastModified();
+ log( "Loading stylesheet " + file, Project.MSG_INFO);
+ liaison.setStylesheet( file.toString() );
for(Enumeration e = params.elements();e.hasMoreElements();) {
Param p = (Param)e.nextElement();
liaison.addParam( p.getName(), p.getExpression() );
@@ -213,15 +214,13 @@
} //-- setDestDir
/**
- * Sets the file to use for styling relative to the base directory.
+ * Sets the file to use for styling relative to the base directory
+ * of this task.
*/
- public void setStyle(File xslFile) {
+ public void setStyle(String xslFile) {
this.xslFile = xslFile;
}
- /**
- * Sets the file to use for styling relative to the base directory.
- */
public void setProcessor(String processor) throws Exception {
if (processor.equals("trax")) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]