Author: mbenson
Date: Tue Sep 19 14:58:19 2006
New Revision: 447990

URL: http://svn.apache.org/viewvc?view=rev&rev=447990
Log:
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. <file> or <url>, or any resource collection known to
evaluate to a single result e.g. <fileset file="foo" /> OR
<style refid="somesingleelementcollection" /> is supported OOTB.  Docs to come.

Modified:
    ant/core/trunk/src/etc/testcases/taskdefs/style/build.xml
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
    
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java

Modified: ant/core/trunk/src/etc/testcases/taskdefs/style/build.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/style/build.xml?view=diff&rev=447990&r1=447989&r2=447990
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/style/build.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/style/build.xml Tue Sep 19 
14:58:19 2006
@@ -109,15 +109,18 @@
   </target>
 
   <target name="testWithStyleAttrAndResource">
-      <property name="value" value="myvalue"/>
+      <!-- also testing style as resources, with refid -->
+      <file id="xslFile" file="printParams.xsl"/>
       <xslt in="data.xml" out="${out.dir}/out.xml" style="printParams.xsl">
-          <file file="printParams.xsl"/>
+        <style refid="xslFile" />
       </xslt>
   </target>
 
   <target name="testWithFileResource">
       <xslt in="data.xml" out="${out.dir}/out.xml">
-          <file file="printParams.xsl"/>
+          <style>
+              <file file="printParams.xsl"/>
+          </style>
           <param name="set" expression="value"/>
       </xslt>
   </target>
@@ -125,7 +128,9 @@
   <target name="testWithUrlResource">
       <makeurl file="printParams.xsl" property="printParams.xsl.url"/>
       <xslt in="data.xml" out="${out.dir}/out.xml">
-          <url url="${printParams.xsl.url}"/>
+          <style>
+              <url url="${printParams.xsl.url}"/>
+          </style>
           <param name="set" expression="value"/>
       </xslt>
   </target>
@@ -180,4 +185,4 @@
       /> <!-- without 'filenameparameter' to check, that the xsl:param is NOT 
set -->
   </target>
 
-</project>
\ No newline at end of file
+</project>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?view=diff&rev=447990&r1=447989&r2=447990
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Tue 
Sep 19 14:58:19 2006
@@ -34,6 +34,7 @@
 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 @@
     }
 
     /**
-     * Adds the XSLT stylesheet as a resource
-     * @param xslResource the stylesheet as a
-     *        [EMAIL PROTECTED] org.apache.tools.ant.types.Resource}
+     * Add a nested &lt;style&gt; element.
+     * @param rc the configured Resources object represented as &lt;style&gt;.
      * @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 @@
         }
     }
 
-}
\ No newline at end of file
+}

Modified: 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java?view=diff&rev=447990&r1=447989&r2=447990
==============================================================================
--- 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
 (original)
+++ 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
 Tue Sep 19 14:58:19 2006
@@ -229,7 +229,8 @@
         XSLTProcess xsltTask = new XSLTProcess();
         xsltTask.bindToOwner(task);
 
-        xsltTask.addConfigured(getStylesheet());
+        xsltTask.setXslResource(getStylesheet());
+
         // acrobatic cast.
         xsltTask.setIn(((XMLResultAggregator) task).getDestinationFile());
         File outputFile = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to