Hello:

The attached patch represents a tiny but significant change to the style task (XSLTProcess.java).

Today the style task checks to see if the stylesheet or source XML file are out of date and only
styles the input file if one or both are.


However, there are circumstances when you want to ALWAYS regenerate the output no matter what.
For example, there may be extra parameters to the stylesheet that might change each invocation,
or other files like external DTD files, included/imported stylesheets, or XMLSchema (XSD) files.


Even if the task tried to detect these addition dependencies (which it does not), some of them
are _undetectable_ (for example: parameters to the stylesheet,
external XSD files not referenced by the XML source, etc.). Correctness demands that we supply
some way to deal with this, and "force" is the Simplest Thing That Could Possibly Work.


Force defaults to false, which preserves the current behavior.

What do you'all think?  I can provide a patch to the docs as well...

Thanks,

--Craeg

--
Craeg K. Strong | www.arielpartners.com
Ariel Partners LLC | [EMAIL PROTECTED] 85 River Street, Ste. 3A | Fax: (781) 647-9690
Waltham, MA 02453 | Voice: (781) 647-2425


Index: XSLTProcess.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java,v
retrieving revision 1.21
diff -u -r1.21 XSLTProcess.java
--- XSLTProcess.java    2001/05/08 09:35:30     1.21
+++ XSLTProcess.java    2001/06/19 22:50:01
@@ -105,6 +105,8 @@
     private XSLTLiaison liaison;
     private boolean stylesheetLoaded = false;
 
+       private boolean force = false;
+
     /**
      * Creates a new XSLTProcess Task.
      **/
@@ -245,6 +247,13 @@
     }
 
     /**
+     * Set whether to check dependencies, or always generate.
+     **/
+    public void setForce(boolean force) {
+                this.force = force;
+    } //-- setForce
+
+    /**
      * Processes the given input XML file and stores the result
      * in the given resultFile.
      **/
@@ -265,8 +274,9 @@
             }else{
                 outFile = new File(destDir,xmlFile+fileExt);
             }
-            if (inFile.lastModified() > outFile.lastModified() ||
-                styleSheetLastModified > outFile.lastModified()) {
+            if ( force == true ||
+                                         inFile.lastModified() > 
outFile.lastModified() ||
+                                               styleSheetLastModified > 
outFile.lastModified() ) {
                 ensureDirectoryFor( outFile );
                 log("Transforming into "+destDir);
 
@@ -293,8 +303,9 @@
             log("In file "+inFile+" time: " + inFile.lastModified() , 
Project.MSG_DEBUG);
             log("Out file "+outFile+" time: " + outFile.lastModified() , 
Project.MSG_DEBUG);
             log("Style file "+xslFile+" time: " + styleSheetLastModified , 
Project.MSG_DEBUG);
-            if (inFile.lastModified() > outFile.lastModified() ||
-                styleSheetLastModified > outFile.lastModified()) {
+            if ( force == true ||
+                                         inFile.lastModified() > 
outFile.lastModified() ||
+                                               styleSheetLastModified > 
outFile.lastModified() ) {
                 ensureDirectoryFor( outFile );
                 log("Processing " + inFile + " to " + outFile, 
Project.MSG_INFO);
                 configureLiaison(stylesheet);

Reply via email to