I downloaded the xmltask-v1.15.1.jar file and placed it in the lib subdirectory 
of my ant installation.

I prepared this web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
   <mime-mapping>
      <extension>html</extension>
      <mime-type>text/html</mime-type>
   </mime-mapping>
</web-app>

I prepared this insert.xml file:

<?xml version="1.0"?>
<mime-mapping>
  <extension>txt</extension>
  <mime-type>text/plain</mime-type>
</mime-mapping>

I then wrote this build.xml file:

<?xml version="1.0"?>
<project name="bc" default="init" basedir=".">
  <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask"/>
  <target name="init">
    <xmltask source="web.xml" dest="web.xml" >
      <insert path="/web-app/mime-mapping[1]" position="before" 
file="insert.xml"/>
    </xmltask>
  </target>
</project>

I then ran ant and got this new web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
   <mime-mapping>
      <extension>txt</extension>
      <mime-type>text/plain</mime-type>
   </mime-mapping>
   <mime-mapping>
      <extension>html</extension>
      <mime-type>text/html</mime-type>
   </mime-mapping>
</web-app>

This appears to do what you want, what part did you leave out?
-- 
Charles Knell
[EMAIL PROTECTED] - email



-----Original Message-----
From:     broken connection <[EMAIL PROTECTED]>
Sent:     Wed, 19 Sep 2007 13:45:17 -0400
To:       "Ant Users List" <[email protected]>
Subject:  Editing an XML file using ant

Hi Friends,

I want to add some extra mime-mappings to an web.xml file  in the deployment
environment using my build script.I am trying using "XMLTASK" but for some
reason it's not working. Is there any other way using ANT to accomplish this
task.

This is what i am trying with XMLTask:

<xmltask source="${dest}/web.xml" dest="${dest}/web.xml" >
   <insert path="/web-app/mime-mapping[1]" position="before" file="
insert.xml">
   </insert>
</xmltask>

It just copies the source web.xml to destination and does not appends
anything.


Thanks
Mick



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to