ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From weiji <nabbl...@hotmail.com>
Subject help with filterchain: using regex filter...
Date Tue, 11 Aug 2009 06:48:01 GMT

Hi,

I'm trying to use Ant to convert an XML file from one format to another.  We
are using it this way in order to generate Flex manifest files for
compilation using the flex command-line compiler.  Basically we have a list
of classes to compile, but they're in one format and the manifest file is in
a slightly different format.  I'm able to do most of the conversion using
filterchains, but I'm stuck on the last portion and I'm hoping someone here
can help me out.

The input file structure looks like this:

.flexLibProperties:

<?xml version="1.0" encoding="UTF-8"?>
<flexLibProperties version="1">
  <includeClasses>
    <classEntry path="some.long.package.name.ClassA"/>
    <classEntry path="some.long.package.name.ClassB"/>
    <classEntry path="some.long.package.name.ClassC"/>
(more classes here)
  </includeClasses>
  <includeResources/>
  <namespaceManifests/>
</flexLibProperties>

The manifest.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<componentPackage>
    <component id="ClassA" class="some.long.package.name.ClassA"/>
    <component id="ClassB" class="some.long.package.name.ClassB"/>
    <component id="ClassC" class="some.long.package.name.ClassC"/>
(more classes here)
</componentPackage>

So far I have the following:

    <target name="testman" description="Convert a .flexLibProperties file
into a manifest file">
        <property name="tempfile" value="manifest.temp"/>
        <property name="outfile"  value="manifest.xml"/>
        <property name="flag.keepme" value="keepme"/>

        <delete file="${tempfile}"/>
        <delete file="${outfile}"/>
        <copy file=".flexLibProperties" tofile="${tempfile}">
            <filterchain>
                <replacestring from="xml version" to="xml ${flag.keepme}
version"/>
                <replacestring from="includeClasses" to="componentPackage
${flag.keepme}"/>
                <replacestring from="classEntry" to="component"/>
                <replacestring from="path=" to="${flag.keepme} id= class="/>
            </filterchain>
        </copy>
        <copy file="${tempfile}" tofile="${outfile}">
            <filterchain>
                <linecontains>
                    <contains value="${flag.keepme}"/>
                </linecontains>
                <replacestring from=" ${flag.keepme}" to=""/>
            </filterchain>
        </copy>
    </target>

This gets me pretty close; the output looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<componentPackage>
    <component id= class="some.long.package.name.ClassA"/>
    <component id= class="some.long.package.name.ClassB"/>
    <component id= class="some.long.package.name.ClassC"/>
(more classes here)
</componentPackage>

The only thing left is to get the class name inserted as the value of the id
attribute.  I can't figure out how to use the regex filters, or if that's
the correct one I should be using. Can anyone lend a hand?

Thanks,
KaJun
-- 
View this message in context: http://www.nabble.com/help-with-filterchain%3A-using-regex-filter...-tp24912535p24912535.html
Sent from the Ant - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message