From 303b70f86bd394282e39affce9ec2a065b5a4ad1 Mon Sep 17 00:00:00 2001
From: Jan Materne
Date: Mon, 17 Jul 2006 12:03:07 +0000
Subject: [PATCH] Bug 21042 "Setting XSL parameter to input filename when
processed whole directory."
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@422692 13f79535-47bb-0310-9956-ffa450edef68
---
CONTRIBUTORS | 1 +
contributors.xml | 4 +
docs/manual/CoreTasks/style.html | 45 +++++-
src/etc/testcases/taskdefs/style/build.xml | 55 ++++++-
.../taskdefs/style/printFilename.xsl | 22 +++
.../tools/ant/taskdefs/XSLTProcess.java | 58 ++++++-
.../ant/taskdefs/optional/TraXLiaison.java | 28 +++-
.../org/apache/tools/ant/util/FileUtils.java | 144 +++++++++++++++++-
.../apache/tools/ant/taskdefs/StyleTest.java | 49 ++++--
9 files changed, 375 insertions(+), 31 deletions(-)
create mode 100644 src/etc/testcases/taskdefs/style/printFilename.xsl
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 45c04e1eb..a3de7235e 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -239,6 +239,7 @@ Tom Cunningham
Tom Dimock
Tom Eugelink
Ulrich Schmidt
+Victor Toni
Waldek Herka
Will Wang
William Ferguson
diff --git a/contributors.xml b/contributors.xml
index 24ae73a23..e5ecb2516 100644
--- a/contributors.xml
+++ b/contributors.xml
@@ -950,6 +950,10 @@
Ulrich
Schmidt
+
+ Victor
+ Toni
+
Will
Wang
diff --git a/docs/manual/CoreTasks/style.html b/docs/manual/CoreTasks/style.html
index 6d823e320..307419721 100644
--- a/docs/manual/CoreTasks/style.html
+++ b/docs/manual/CoreTasks/style.html
@@ -16,7 +16,7 @@
or for generating code.
Note: If you are using JDK 1.4 or higher, this task does not require external libraries
not supplied in the Ant distribution. However, often the built in XSL engine is not as up
-to date as a fresh download, so an update is still highly recommended.
+to date as a fresh download, so an update is still highly recommended.
See Library Dependencies for more information.
It is possible to refine the set of files that are being processed. This can be
done with the includes, includesfile, excludes, excludesfile and defaultexcludes
@@ -189,6 +189,22 @@ element which is used to perform Entity and URI resolution.
Since Ant 1.7.
No |
+
+ filenameparameter |
+ 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 |
+
+
+ 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.
+ Since Ant 1.7. |
+ No |
+
Parameters specified as nested elements
@@ -312,7 +328,7 @@ And in Saxon 7.x:
http://saxon.sf.net/feature/linenumbering (integer)
...
-
+
Parameters
@@ -417,10 +433,33 @@ See resources to see the concrete synt
<param name="set" expression="value"/>
</xslt>
+ Print the current processed file name
+
+<project>
+ <xslt style="printFilename.xsl" destdir="out" basedir="in" extension=".txt"
+ filenameparameter="filename"
+ filedirparameter="filedir"
+ />
+</project>
+
+<xsl:stylesheet
+ version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="filename"></xsl:param>
+ <xsl:param name="filedir">.</xsl:param>
+
+<xsl:template match="/">
+ Current file is <xsl:value-of select="$filename"/> in directory <xsl:value-of select="$filedir"/>.
+</xsl:template>
+
+</xsl:stylesheet>
+
+
Copyright © 2000-2006 The Apache Software Foundation. All rights
Reserved.