Yoshiki Hayashi [EMAIL PROTECTED] writes:
3. Modify Ant to meet our requirements. Use that jar
throughout the project by putting it to somewhere like
site-tools.
There are two ways to achieve it:
1. Replace xml with supplied extension
2. Enhance style rule to allow nested mapper element
I first tried option 1 but I found out that I actulally want
to map .xml.ja to .xml.ja.jis so I went to implement option
2.
Here's a patch. This one is against Ant 1.4.1. I'll send a
patch against 1.5 Beta1 to Ant people, probably via
bugzilla.
This patch allows you to put something like
mapper type=glob from=*.xml.ja to=*.html.ja.jis
and
mapper type=glob from=*.xml to = *.xml.en
inside style element.
diff -ur
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
jakarta-ant-1.4.1/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
---
jakarta-ant-1.4.1.orig/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
Thu Oct 11 22:58:29 2001
+++ jakarta-ant-1.4.1/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
Wed May 22 18:48:14 2002
@@ -61,9 +61,11 @@
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tools.ant.*;
+import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.FileNameMapper;
/**
@@ -99,6 +101,7 @@
private String xslFile = null;
private String targetExtension = .html;
+private Mapper mapperElement = null;
private Vector params = new Vector();
private File inFile = null;
@@ -311,6 +314,18 @@
}
/**
+ * Defines the FileNameMapper to use (nested mapper element).
+ */
+public Mapper createMapper() throws BuildException {
+if (mapperElement != null) {
+throw new BuildException(Cannot define more than one mapper,
+ location);
+}
+mapperElement = new Mapper(project);
+return mapperElement;
+}
+
+/**
* Processes the given input XML file and stores the result
* in the given resultFile.
**/
@@ -326,7 +341,15 @@
long styleSheetLastModified = stylesheet.lastModified();
inFile = new File(baseDir,xmlFile);
int dotPos = xmlFile.lastIndexOf('.');
-if(dotPos0){
+if (mapperElement != null) {
+FileNameMapper mapper = mapperElement.getImplementation();
+String[] fileNames = mapper.mapFileName(xmlFile);
+if (fileNames != null) {
+outFile = new File(destDir, fileNames[0]);
+} else {
+outFile = new File(destDir, xmlFile + fileExt);
+}
+} else if(dotPos0){
outFile = new
File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt);
}else{
outFile = new File(destDir,xmlFile+fileExt);
--
Yoshiki Hayashi
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]