From 2cec63f68a7d43b7645135df6ba8da3a84cce912 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Sun, 4 Sep 2016 16:24:18 +0200 Subject: [PATCH] allow Ant references to be used for xslt attributes --- WHATSNEW | 3 ++ manual/Tasks/style.html | 32 ++++++++++++++++++- .../tools/ant/taskdefs/XSLTProcess.java | 13 +++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 3a23c1f13..7a9e070f7 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -86,6 +86,9 @@ Other changes: * it is now possible to set features of the TraX factory used by and . + * it is now possible to use references to Ant types and classloaders + built around Ant s as values for TraX factory attributes. + Changes from Ant 1.9.6 TO Ant 1.9.7 =================================== diff --git a/manual/Tasks/style.html b/manual/Tasks/style.html index 32fa6214a..5eda02667 100644 --- a/manual/Tasks/style.html +++ b/manual/Tasks/style.html @@ -431,9 +431,39 @@ And in Saxon 7.x: value value of the attribute. - Yes + Exactly one of these + + + valueref + value of the attribute is the value of the + project reference with the given id. since Ant 1.9.8 + + + classloaderforpath + value of the attribute is a classloader that uses + the classpath specified by a path that is the project reference + with the given id. since Ant 1.9.8 + +

Examples

+ +
+  <path id="extension-path">
+    ...
+  </path>
+
+
+  <xslt ...>
+    <factory>
+      <attribute name="jdk.xml.transform.extensionClassLoader"
+                 classloaderforpath="extension-path"/>
+    </factory>
+  </xslt ...>
+
+

Sets the classloader to use when loading extension functions to a + classloader using the path with the + id extension-path.

feature

since Ant 1.9.8

diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 6f54d1d4c..f9c53eaab 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -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 { *
  • http://xml.apache.org/xalan/features/incremental (true|false)
  • * */ - 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); }