From 427c2d293d2ae1e6fd446967a5936e948dfb647b Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Tue, 19 Sep 2006 21:58:19 +0000 Subject: [PATCH] Have to fix fix from bug 39407, because a nested resource and a nested resource collection are ambiguous; all resources are resource collections. Added addConfiguredStyle(Resources) for maximum ease of use; user can specify a nested resource e.g. or , or any resource collection known to evaluate to a single result e.g. OR @@ -125,7 +128,9 @@ - + @@ -180,4 +185,4 @@ /> - \ No newline at end of file + diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index 02896de98..d93edd440 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -34,6 +34,7 @@ import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.ResourceCollection; import org.apache.tools.ant.types.XMLCatalog; 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.FileNameMapper; import org.apache.tools.ant.util.FileUtils; @@ -222,13 +223,25 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { } /** - * Adds the XSLT stylesheet as a resource - * @param xslResource the stylesheet as a - * {@link org.apache.tools.ant.types.Resource} + * Add a nested <style> element. + * @param rc the configured Resources object represented as <style>. * @since Ant 1.7 */ - public void addConfigured(Resource xslResource) { - this.xslResource = xslResource; + public void addConfiguredStyle(Resources rc) { + if (rc.size() != 1) { + throw new BuildException("The style element must be specified" + + " with exactly one nested resource."); + } + setXslResource((Resource) rc.iterator().next()); + } + + /** + * API method to set the XSL Resource. + * @param xslResource Resource to set as the stylesheet. + * @since Ant 1.7 + */ + public void setXslResource(Resource xslResource) { + this.xslResource = xslResource; } /** @@ -1204,4 +1217,4 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { } } -} \ No newline at end of file +} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java index 13ef98753..92e902e3a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java @@ -229,7 +229,8 @@ public class AggregateTransformer { XSLTProcess xsltTask = new XSLTProcess(); xsltTask.bindToOwner(task); - xsltTask.addConfigured(getStylesheet()); + xsltTask.setXslResource(getStylesheet()); + // acrobatic cast. xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile()); File outputFile = null;