Browse Source

Bug ID 43635 <xslt> task can't be used more than once with a file stylesheet

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@585108 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 17 years ago
parent
commit
19b4f6ae89
1 changed files with 13 additions and 8 deletions
  1. +13
    -8
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 13
- 8
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -35,6 +35,7 @@ import org.apache.tools.ant.types.XMLCatalog;
import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.Resources; import org.apache.tools.ant.types.resources.Resources;
import org.apache.tools.ant.types.resources.Union; import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.util.FileNameMapper; import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;


@@ -285,8 +286,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
throw new BuildException("input file " + inFile + " does not exist", getLocation()); throw new BuildException("input file " + inFile + " does not exist", getLocation());
} }
try { try {
Resource styleResource;
if (baseDir == null) { if (baseDir == null) {
baseDir = getProject().resolveFile(".");
baseDir = getProject().getBaseDir();
} }
liaison = getLiaison(); liaison = getLiaison();


@@ -315,11 +317,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
FileResource fr = new FileResource(); FileResource fr = new FileResource();
fr.setProject(getProject()); fr.setProject(getProject());
fr.setFile(stylesheet); fr.setFile(stylesheet);
xslResource = fr;
styleResource = fr;
} else {
styleResource = xslResource;
} }
// if we have an in file and out then process them // if we have an in file and out then process them
if (inFile != null && outFile != null) { if (inFile != null && outFile != null) {
process(inFile, outFile, xslResource);
process(inFile, outFile, styleResource);
return; return;
} }
/* /*
@@ -337,7 +341,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
// Process all the files marked for styling // Process all the files marked for styling
list = scanner.getIncludedFiles(); list = scanner.getIncludedFiles();
for (int i = 0; i < list.length; ++i) { for (int i = 0; i < list.length; ++i) {
process(baseDir, list[i], destDir, xslResource);
process(baseDir, list[i], destDir, styleResource);
} }
if (performDirectoryScan) { if (performDirectoryScan) {
// Process all the directories marked for styling // Process all the directories marked for styling
@@ -346,7 +350,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
list = new File(baseDir, dirs[j]).list(); list = new File(baseDir, dirs[j]).list();
for (int i = 0; i < list.length; ++i) { for (int i = 0; i < list.length; ++i) {
process(baseDir, dirs[j] + File.separator + list[i], destDir, process(baseDir, dirs[j] + File.separator + list[i], destDir,
xslResource);
styleResource);
} }
} }
} }
@@ -355,7 +359,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
throw new BuildException("no resources specified"); throw new BuildException("no resources specified");
} }
} }
processResources(xslResource);
processResources(styleResource);
} finally { } finally {
if (loader != null) { if (loader != null) {
loader.resetThreadContextLoader(); loader.resetThreadContextLoader();
@@ -575,6 +579,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
/** /**
* Styles all existing resources. * Styles all existing resources.
* *
* @param stylesheet style sheet to use
* @since Ant 1.7 * @since Ant 1.7
*/ */
private void processResources(Resource stylesheet) { private void processResources(Resource stylesheet) {
@@ -983,8 +988,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
// If we are here we cannot set the stylesheet as // If we are here we cannot set the stylesheet as
// a resource, but we can set it as a file. So, // a resource, but we can set it as a file. So,
// we make an attempt to get it as a file // we make an attempt to get it as a file
if (stylesheet instanceof FileResource) {
liaison.setStylesheet(((FileResource) stylesheet).getFile());
if (stylesheet instanceof FileProvider) {
liaison.setStylesheet(((FileProvider) stylesheet).getFile());
} else { } else {
throw new BuildException(liaison.getClass().toString() throw new BuildException(liaison.getClass().toString()
+ " accepts the stylesheet only as a file", getLocation()); + " accepts the stylesheet only as a file", getLocation());


Loading…
Cancel
Save