Browse Source

destdir in <style> is no longer required if in/out have been specified.

Suggested by:	Will Holcomb <will@odin.himinbi.org>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268861 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
8237734548
2 changed files with 48 additions and 31 deletions
  1. +5
    -3
      docs/manual/CoreTasks/style.html
  2. +43
    -28
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 5
- 3
docs/manual/CoreTasks/style.html View File

@@ -36,13 +36,15 @@ inclusion/exclusion of files works, and how to write patterns.</p>
</tr>
<tr>
<td valign="top">basedir</td>
<td valign="top">where to find the source XML file.</td>
<td align="center" valign="top">Yes</td>
<td valign="top">where to find the source XML file, default is the
project's basedir.</td>
<td align="center" valign="top">No</td>
</tr>
<tr>
<td valign="top">destdir</td>
<td valign="top">directory in which to store the results.</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="top">Yes, unless in and out have been
specified.</td>
</tr>
<tr>
<td valign="top">extension</td>


+ 43
- 28
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -122,32 +122,7 @@ public class XSLTProcess extends MatchingTask {
baseDir = project.resolveFile(".");
}
//-- make sure Source directory exists...
if (destDir == null ) {
String msg = "destdir attributes must be set!";
throw new BuildException(msg);
}
scanner = getDirectoryScanner(baseDir);
log("Transforming into "+destDir, Project.MSG_INFO);

// if processor wasn't specified, see if TraX is available. If not,
// default it to xslp or xalan, depending on which is in the classpath
if (liaison == null) {
try {
setProcessor("trax");
} catch (Throwable e1) {
try {
setProcessor("xslp");
} catch (Throwable e2) {
try {
setProcessor("xalan");
} catch (Throwable e3) {
throw new BuildException(e1);
}
}
}
}

liaison = getLiaison();
log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE);

long styleSheetLastModified = 0;
@@ -156,9 +131,15 @@ public class XSLTProcess extends MatchingTask {
File file = project.resolveFile(xslFile, project.getBaseDir());

if (!file.exists()) {
log("DEPRECATED - the style attribute should be relative to the project\'s");
log(" basedir, not the tasks\'s basedir.");
file = project.resolveFile(xslFile, baseDir);
/*
* shouldn't throw out deprectaion warnings before we know,
* the wrong version has been used.
*/
if (file.exists()) {
log("DEPRECATED - the style attribute should be relative to the project\'s");
log(" basedir, not the tasks\'s basedir.");
}
}
// Create a new XSL processor with the specified stylesheet
@@ -181,6 +162,19 @@ public class XSLTProcess extends MatchingTask {
return;
}

/*
* if we get here, in and out have not been specified, we are
* in batch processing mode.
*/

//-- make sure Source directory exists...
if (destDir == null ) {
String msg = "destdir attributes must be set!";
throw new BuildException(msg);
}
scanner = getDirectoryScanner(baseDir);
log("Transforming into "+destDir, Project.MSG_INFO);

// Process all the files marked for styling
list = scanner.getIncludedFiles();
for (int i = 0;i < list.length; ++i) {
@@ -331,6 +325,27 @@ public class XSLTProcess extends MatchingTask {
}
}
protected XSLTLiaison getLiaison() {
// if processor wasn't specified, see if TraX is available. If not,
// default it to xslp or xalan, depending on which is in the classpath
if (liaison == null) {
try {
setProcessor("trax");
} catch (Throwable e1) {
try {
setProcessor("xslp");
} catch (Throwable e2) {
try {
setProcessor("xalan");
} catch (Throwable e3) {
throw new BuildException(e1);
}
}
}
}
return liaison;
}

public Param createParam() {
Param p = new Param();
params.addElement(p);


Loading…
Cancel
Save