You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by broken connection <br...@gmail.com> on 2007/09/19 19:45:17 UTC

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

Re: Editing an XML file using ant

Posted by Robert Koberg <ro...@koberg.com>.
On Wed, 2007-09-19 at 14:42 -0400, broken connection wrote:
> Thanks for the advice..i am trying to do that but it's a deprecated task and
> i am getting ClassNotFound exception for
> org.apache.tools.ant.taskdefs.optional.TreXLiaison

It is not deprecated. The Style task (which is the same thing) is
deprecated.


> 
> 
> I think,I need an optional.jar file...can you tell me where to download it
> from,i cannot find it anywhere on net.

http://ant.apache.org/bindownload.cgi

It is a core task, but I have heard before that you need the optional
jar to make the xslt task work (I have always used the full distro so I
have never run into the problem)

best,
-Rob

> 
> Thanks
> 
> 
> 
> On 9/19/07, Robert Koberg <ro...@koberg.com> wrote:
> >
> > On Wed, 2007-09-19 at 13:45 -0400, broken connection wrote:
> > > 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.
> >
> > You could use the XSLT task with:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > version="1.0">
> >   <xsl:template match="@*|node()">
> >     <xsl:copy>
> >       <xsl:apply-templates select="@*"/>
> >       <xsl:apply-templates/>
> >     </xsl:copy>
> >   </xsl:template>
> >
> >   <xsl:template match="mime-mapping[1]">
> >     <xsl:apply-templates select="document('insert.xml')/*"/>
> >     <xsl:copy-of select="."/>
> >     <xsl:apply-templates/>
> >   </xsl:template>
> > </xsl:stylesheet>
> >
> >
> > >
> > > 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: user-unsubscribe@ant.apache.org
> > For additional commands, e-mail: user-help@ant.apache.org
> >
> >


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


Re: Editing an XML file using ant

Posted by broken connection <br...@gmail.com>.
Thanks for the advice..i am trying to do that but it's a deprecated task and
i am getting ClassNotFound exception for
org.apache.tools.ant.taskdefs.optional.TreXLiaison


I think,I need an optional.jar file...can you tell me where to download it
from,i cannot find it anywhere on net.

Thanks



On 9/19/07, Robert Koberg <ro...@koberg.com> wrote:
>
> On Wed, 2007-09-19 at 13:45 -0400, broken connection wrote:
> > 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.
>
> You could use the XSLT task with:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
>   <xsl:template match="@*|node()">
>     <xsl:copy>
>       <xsl:apply-templates select="@*"/>
>       <xsl:apply-templates/>
>     </xsl:copy>
>   </xsl:template>
>
>   <xsl:template match="mime-mapping[1]">
>     <xsl:apply-templates select="document('insert.xml')/*"/>
>     <xsl:copy-of select="."/>
>     <xsl:apply-templates/>
>   </xsl:template>
> </xsl:stylesheet>
>
>
> >
> > 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: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: Editing an XML file using ant

Posted by Robert Koberg <ro...@koberg.com>.
On Wed, 2007-09-19 at 13:45 -0400, broken connection wrote:
> 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.

You could use the XSLT task with:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="mime-mapping[1]">
    <xsl:apply-templates select="document('insert.xml')/*"/>
    <xsl:copy-of select="."/>
    <xsl:apply-templates/>
  </xsl:template>
</xsl:stylesheet>


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