ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Matèrne (jhm) <>
Subject AW: getting information out of the source file and using it in apply tasks
Date Fri, 02 Aug 2013 06:11:04 GMT
My idea is reading the SGML file using some filterchains and regexps for extracting the DTD-name.
But I dont know any way to inject that into <apply>.

So the workaround here is iterating over the <srcfile> for yourself
- antcontrib: for, foreach
- loop using script (bsh, groovy, javascript) inside the buildfile


> -----Urspr√ľngliche Nachricht-----
> Von: Graydon Saunders []
> Gesendet: Donnerstag, 1. August 2013 22:36
> An:
> Betreff: getting information out of the source file and using it in
> apply tasks
> Hi --
> I'm using ant 1.9.2  via a Fedora rawhide package on Linux.
> I have bunch of SGML files (in complex, arbitrary directory structures
> which I must preserve) that have different SGML DTDs; these need to be
> normalized to XML.
> One of the pieces of information required by the program that does the
> normalization is the name of the SGML DTD.
> That's in the SGML -- and thus effectively text, it can't be treated as
> raw XML -- source file as a processing instruction, <?dtd
> name="oneOfMany"> -- and I'm not seeing how I should get that
> information out of there and make it available to the apply task.
> As a general structure
> <target depends="prepSGML"
>     description="normalize SGML input to XML (but not the target XML!)"
> name="normalize">
>     <mkdir dir="${NORMALIZED}"/>
>     <antcall target="copy.only.dir">
>       <param name="dest.dir" value="SX"/>
>       <param name="source.dir" value="SPrep"/>
>     </antcall>
>     <mapper from="*" id="normOut" to="SX/*" type="glob"/>
>     <apply executable="osx" failonerror="true" logerror="true">
>       <env file="${srcfile}" />
>       <fileset casesensitive="no" dir="${SPREP}" id="prepSGML">
>         <include name="**/*.dat"/>
>       </fileset>
>       <mapper refid="normOut"/>
>       <arg value="--xml-output-option=comment"/>
>       <arg value="--catalog=${ENTITIES}/catalog"/>
>       <arg value="${SGML_DTD}/prep.dtd"/>
>       <srcfile/>
>       <redirector>
>         <outputmapper refid="normOut"/>
>       </redirector>
>     </apply>
>   </target>
> works.
> The problem is
>  <arg value="${SGML_DTD}/prep.dtd"/>
> where I've hard-coded the dtd name.  That obviously won't work in the
> general case, even if it convinces me the target works by correctly
> normalizing a single sample file.  (I've used ant before, but it's been
> awhile.)
> I can't shake the sense that this ought to be obvious if I were only
> looking at the problem in a suitably ant-like way, but I'm not having
> much luck; I've been over the apply documentation and various other
> things repeatedly, trying to figure out how to set a property based on
> individual
> files in a fileset, and having no luck.   Which makes me think that's
> probably the wrong approach.
> Anyone care to suggest how to approach this?  I'd like to stick to core
> ant if at all possible.
> Thanks!
> Graydon

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message