diff --git a/docs/manual/CoreTasks/style.html b/docs/manual/CoreTasks/style.html
index 307419721..01271b367 100644
--- a/docs/manual/CoreTasks/style.html
+++ b/docs/manual/CoreTasks/style.html
@@ -191,8 +191,8 @@ element which is used to perform Entity and URI resolution.
filenameparameter |
- Specifies a xsl parameter for accessing the name
- of the current processed file. If not set, the file name is not
+ | Specifies a xsl parameter for accessing the name
+ of the current processed file. If not set, the file name is not
passed to the transformation.
Since Ant 1.7. |
No |
@@ -200,8 +200,9 @@ element which is used to perform Entity and URI resolution.
filedirparameter |
Specifies a xsl parameter for accessing the directory
- of the current processed file. If not set, the directory is not
- passed to the transformation.
+ of the current processed file. For files in the current directory a
+ value of '.' will be passed to the transformation.
+ If not set, the directory is not passed to the transformation.
Since Ant 1.7. |
No |
@@ -454,7 +455,7 @@ See resources to see the concrete synt
</xsl:template>
</xsl:stylesheet>
-
+
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
index dff574c90..315540212 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
@@ -1037,13 +1037,23 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
File inFile
) throws Exception {
String fileName = FileUtils.getRelativePath(baseDir, inFile);
- File file = new File(fileName);
-
+
+ String name;
+ String dir;
+ int lastDirSep = fileName.lastIndexOf("/");
+ if (lastDirSep > -1) {
+ name = fileName.substring(lastDirSep + 1);
+ dir = fileName.substring(0, lastDirSep);
+ } else {
+ name = fileName;
+ dir = "."; // so a dir+"/"+name would not result in an absolute path
+ }
+
if (fileNameParameter != null) {
- liaison.addParam(fileNameParameter, inFile.getName());
+ liaison.addParam(fileNameParameter, name);
}
if (fileDirParameter != null) {
- liaison.addParam(fileDirParameter, (file.getParent()!=null) ? file.getParent() : "" );
+ liaison.addParam(fileDirParameter, dir);
}
}
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java b/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java
index be6063565..60d9fd22a 100644
--- a/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java
+++ b/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java
@@ -168,7 +168,7 @@ public class StyleTest extends BuildFileTest {
public void testFilenameAndFiledirAsParam() throws Exception {
executeTarget("testFilenameAndFiledirAsParam");
assertFileContains("out/out/one.txt", "filename='one.xml'");
- assertFileContains("out/out/one.txt", "filedir =''");
+ assertFileContains("out/out/one.txt", "filedir ='.'");
assertFileContains("out/out/dir/four.txt", "filename='four.xml'");
assertFileContains("out/out/dir/four.txt", "filedir ='dir'");
}