If you're ok with including an extra couple of build files you can have a look 
at
http://codepulsive.blogspot.com.au/2013/05/ant-edit-property-values.html
and
http://codepulsive.blogspot.com.au/2013/05/ant-process-elements-in-list.html

The relevant build files are
http://pbw.id.au/src/ant/editstring.xml
and
http://pbw.id.au/src/ant/listutils.xml

All standard ant, no compiled components.

Peter West

"Ask and it will be given you; seek, and you will find; knock, and it will be 
opened to you."

On 02/08/2013, at 6:35 AM, Graydon Saunders <graydon...@gmail.com> wrote:

> 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: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to