ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "W. Sean Hennessy" <shenne...@goldenhourdata.com>
Subject RE: Getting the name of the current file in a fileset
Date Wed, 04 Jun 2003 15:49:49 GMT
use javascript to get at the fileset at inception..

  <!-- =============================== -->
  <!-- Selective Xml SrcFiles          -->
  <!-- =============================== -->
  <patternset id="proj.dbook.ptset">
     <include name="**/*.COD.xml"/>
     <include name="**/*.DBDD.xml" />
     <include name="**/*.FLRS.xml"/>
     <include name="**/*.RTM.xml"/>
     <include name="**/*.SAD.xml"/>
     <include name="**/*.SARAD.xml"/>
     <include name="**/*.SDP.xml"/>
     <include name="**/*.SDS.xml"/>
     <include name="**/*.SEM.xml"/>
     <include name="**/*.SRS.xml"/>
     <include name="**/*.VIS.xml"/>
  </patternset>

<target name="gen.proj.doc" >
  <path id="dbookfiles.path" >
  <fileset id="srcfs" dir="${SEE.SDF.DocFolder}">
     <patternset refid="proj.dbook.ptset"/>
  </fileset>
  </path>

  <script language="javascript"> <![CDATA[
        importPackage(Packages.org.apache.tools.ant.types);
        importPackage(Packages.org.apache.tools.ant.taskdefs);
        importPackage(java.util);
        var tstrEchoMsg = new String(" ==================
proc.xslt.docbook.");
        var tstrEchoMsgSfx = new String();
        prj = self.getProject();

        // Get the DirectoryScanner
        // project is an object defined by script task
        tDirectoryScanner = srcfs.getDirectoryScanner(project);
        // Get the source files (array)
        srcFiles = tDirectoryScanner.getIncludedFiles();

        echo = prj.createTask("echo");
        echo.setMessage(" ================== proc.xslt.docbook Start");
        echo.execute();
        for (var i1=0;i1<srcFiles.length;i1++)
        {
           tstrEchoMsgSfx = tstrEchoMsg + i1.toString();
           echo.setMessage( tstrEchoMsgSfx );
           echo.execute();
           filename = srcFiles[i1];
           antcall=project.createTask("antcall");
           antcall.init();
           antcall.setTarget("proc.xslt.docbook");
           antcallParam=antcall.createParam();
           antcallParam.setName("proc.xslt.docbook.inp.file");
           antcallParam.setValue( filename); // just filename..not full path
:(
           antcall.execute();
        }
        echo.setMessage(" ================== proc.xslt.docbook End");
        echo.execute();
    ]]> </script>
</target>

<target name="proc.xslt.docbook" >
   <echo message="proc.xslt.docbook with ${proc.xslt.docbook.inp.file}"/>
   <antcall target="exec.proc.docbook" inheritAll="true">
   <param name="out.dir" value="${build.dir}"/>
   <param name="main.infile"
value="${SEE.SDF.DocFolder}${file.separator}${proc.xslt.docbook.inp.file}"/>
   <param name="main.outfile" value="${proc.xslt.docbook.inp.file}"/>
   </antcall>

</target>

-----Original Message-----
From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
Sent: Wednesday, June 04, 2003 3:30 AM
To: user@ant.apache.org
Subject: AW: Getting the name of the current file in a fileset


I think the only way is to use AntContrib┬┤s <foreach>.
This topic is already discussed on
http://marc.theaimsgroup.com/?l=ant-user&m=104464267224692&w=2

Maybe we can add a property ${xmlfile} which is set by <xslt> and can be
used in nested <param> tags.
<xslt dir="" xsl="">
    <param name="thefile" value="${xmlfile}"/>
</xslt>
So the stylesheet can use its "thefile".

Maybe a little work in XSLTProcess.process(File baseDir, String xmlFile,
File destDir, File stylesheet).


Jan



Ant-Contrib:
  Homepage:   http://sourceforge.net/projects/ant-contrib/
  CVS-Source:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/src/n
et/sf/antcontrib/
  CVS-Manual:
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/ant-contrib/manua
l/index.html

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/ant-contrib/ant-co
ntrib/manual/tasks/index.html
  Binary:     http://gump.covalent.net/jars/latest/ant-contrib/



> -----Urspr├╝ngliche Nachricht-----
> Von: martin.me.roberts@bt.com [mailto:martin.me.roberts@bt.com]
> Gesendet am: Mittwoch, 4. Juni 2003 12:10
> An: user@ant.apache.org
> Betreff: Getting the name of the current file in a fileset
>
> Hi,
>         I need to get the current file name so I can pass it
> into the xslt
> task as a value for the stylesheet.  How do I do this?  Is
> there a property
> for this?
>
> 	Martin Roberts
>
>
>



Mime
View raw message