Re: Problem in ant replace task and replaceregexp task to update xml

Discussion in 'Java' started by Victor, Sep 1, 2004.

  1. Victor

    Victor Guest

    Problem solved -- simply use the jakata ono with ant.


    (Victor) wrote in message news:<>...
    > Dear all,
    >
    > I am having a problem in using the ant task replace to update the
    > following xml file:
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <!DOCTYPE application PUBLIC "-//Sun Microsystems, Inc.//DTD J2EE
    > Application 1.3//EN" "http://java.sun.com/dtd/application_1_3.dtd">
    > <application>
    > <display-name>TestServer</display-name>
    > <module>
    > <ejb>EJB1.jar</ejb>
    > </module>
    > <module>
    > <ejb>EJB2.jar</ejb>
    > </module>
    > <module>
    > <ejb>EJB3.jar</ejb>
    > </module>
    > <module>
    > <web>
    > <web-uri>web.war</web-uri>
    > <context-root>testme</context-root>
    > </web>
    > </module>
    > </application>
    >
    > I just want to remove the Web module in the above xml, that is:
    >
    > ....
    > <module>
    > <web>
    > <web-uri>web.war</web-uri>
    > <context-root>testme</context-root>
    > </web>
    > </module>
    > .....
    >
    > I have tried to use the replace task as following:
    >
    > <project name="ReplacementTest" default="test" basedir=".">
    >
    > <target name="test">
    >
    > <echo message="Going to remove the war module in the file
    > now..."/>
    >
    > <replace file="c:\ant build\test\application.xml">
    > <replacetoken><![CDATA[<module>
    > <web>
    > <web-uri>web.war</web-uri>
    > <context-root>testme</context-root>
    > </web>
    > </module>]]>
    > </replacetoken>
    > <replacevalue>><![CDATA[ ]]></replacevalue>
    >
    > </replace>
    >
    > </target>
    >
    > </project>
    >
    > And it just doesn't work.
    >
    > At the same time, I also attempt to use the replaceregexp as
    > following:
    >
    > <project name="ReplacementTest" default="test" basedir=".">
    >
    > <target name="test">
    >
    > <echo message="Going to remove the war module in the file
    > now..."/>
    >
    > <replaceregexp file= "c:\ant build\test\application.xml" flags=
    > "s" >
    > <regexp pattern="(&lt;module&gt;)(&lt;web&gt;)(.*?)(&lt;/web&gt;)(&lt;/module&gt;)"
    > />
    > <substitution expression="" />
    > </replaceregexp >
    >
    > </target>
    >
    > </project>
    >
    > And it keep giving me the " No supported regular expression matcher
    > found" error.
    >
    > Could anyone give me a help on this?
    >
    > Thanks very much in advance!!!
    >
    > Victor
     
    Victor, Sep 1, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darpan
    Replies:
    3
    Views:
    12,964
    Darpan
    Mar 2, 2005
  2. Replies:
    7
    Views:
    9,650
    Jeff Higgins
    Mar 19, 2006
  3. krabhi
    Replies:
    1
    Views:
    9,320
    Marco Meschieri
    Aug 9, 2006
  4. jespersahner

    Ant replace task / casesensitivity

    jespersahner, Jul 26, 2006, in forum: Java
    Replies:
    0
    Views:
    530
    jespersahner
    Jul 26, 2006
  5. teggy
    Replies:
    0
    Views:
    822
    teggy
    May 29, 2007
Loading...

Share This Page