Browse Source

allow Ant references to be used for xslt attributes

master
Stefan Bodewig 8 years ago
parent
commit
2cec63f68a
3 changed files with 46 additions and 2 deletions
  1. +3
    -0
      WHATSNEW
  2. +31
    -1
      manual/Tasks/style.html
  3. +12
    -1
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 3
- 0
WHATSNEW View File

@@ -86,6 +86,9 @@ Other changes:
* it is now possible to set features of the TraX factory used by <xslt>
and <junitreport>.

* it is now possible to use references to Ant types and classloaders
built around Ant <path>s as values for TraX factory attributes.

Changes from Ant 1.9.6 TO Ant 1.9.7
===================================



+ 31
- 1
manual/Tasks/style.html View File

@@ -431,9 +431,39 @@ And in Saxon 7.x:
<tr>
<td valign="top">value</td>
<td valign="top">value of the attribute.</td>
<td align="center" valign="top">Yes</td>
<td align="center" valign="middle" rowspan="3">Exactly one of these</td>
</tr>
<tr>
<td valign="top">valueref</td>
<td valign="top">value of the attribute is the value of the
project reference with the given id. <em>since Ant 1.9.8</em></td>
</tr>
<tr>
<td valign="top">classloaderforpath</td>
<td valign="top">value of the attribute is a classloader that uses
the classpath specified by a path that is the project reference
with the given id. <em>since Ant 1.9.8</em></td>
</tr>
</table>

<h4>Examples</h4>

<pre>
&lt;path id="extension-path"&gt;
...
&lt;/path&gt;


&lt;xslt ...&gt;
&lt;factory&gt;
&lt;attribute name="jdk.xml.transform.extensionClassLoader"
classloaderforpath="extension-path"/&gt;
&lt;/factory&gt;
&lt;/xslt ...&gt;
</pre>
<p>Sets the classloader to use when loading extension functions to a
classloader using the <code>path</code> with the
id <code>extension-path</code>.
</blockquote>
<h4>feature</h4>
<p><em>since Ant 1.9.8</em></p>


+ 12
- 1
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -39,6 +39,7 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.DynamicConfigurator;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.ProjectComponent;
import org.apache.tools.ant.PropertyHelper;
import org.apache.tools.ant.types.CommandlineJava;
import org.apache.tools.ant.types.Environment;
@@ -53,6 +54,7 @@ import org.apache.tools.ant.types.resources.FileProvider;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.Resources;
import org.apache.tools.ant.types.resources.Union;
import org.apache.tools.ant.util.ClasspathUtils;
import org.apache.tools.ant.util.FileNameMapper;
import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.ResourceUtils;
@@ -1525,7 +1527,9 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
* <li>http://xml.apache.org/xalan/features/incremental (true|false) </li>
* </ul>
*/
public static class Attribute implements DynamicConfigurator {
public static class Attribute
extends ProjectComponent
implements DynamicConfigurator {

/** attribute name, mostly processor specific */
private String name;
@@ -1582,6 +1586,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
this.value = value;
}
}
} else if ("valueref".equalsIgnoreCase(name)) {
this.value = getProject().getReference(value);
} else if ("classloaderforpath".equalsIgnoreCase(name)) {
this.value =
ClasspathUtils.getClassLoaderForPath(getProject(),
new Reference(getProject(),
value));
} else {
throw new BuildException("Unsupported attribute: " + name);
}


Loading…
Cancel
Save