Have a look at these two revised files from my earlier proposed solution. By 
adding the namespaces to the root element in both insert.xml and web.xml, you 
will get the output you want, and the namespace declarations appear only once, 
in the root element of the output.

insert.xml
================
<?xml version="1.0"?>
<mime-mapping
    xmlns="http://java.sun.com/xml/ns/javaee";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee";
    version="2.5">
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
</mime-mapping>

web.xml
================
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee";
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
         version="2.5"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee";>
   <mime-mapping>
      <extension>html</extension>
      <mime-type>text/html</mime-type>
   </mime-mapping>
</web-app>
-- 
Charles Knell
[EMAIL PROTECTED] - email



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

OK Guys,
Finally I figured it out:
XMLTask is very smart enough to understand the namespaces just by adding a
"colon" in front i.e:

<insert path="/:web-app/:mime-mapping[last()]" position="after" file"
insert.xml" />

And everything works fine.

I small thing i noticed is that it adds an empty "xmlns" to all the
mime-mappings i added,i don't know why....i.e.

<mime-mapping xmlns="" >

How can i change the status of this message as "SOLVED".

Thanks a lot guys


On 9/19/07, broken connection <[EMAIL PROTECTED]> wrote:
>
> Thanks Dominique,
>
> I understand and XMLTask uses XPath to map to that element and it's not
> able to map to that web-app because of namespace. So, I am trying to use
> this to make it map to the namespace web-app but it's not working:
>
> <insert path="//*[local-name()='web-app']/mime-mapping[last()]"
> position="after" file"insert.xml" />
>
>
> So, how can i make XPath find the namespace enabled web-app that comes
> with Tomcat ???
>
> Thanks
>
>
> On 9/19/07, Dominique Devienne <[EMAIL PROTECTED]> wrote:
> >
> > On 9/19/07, broken connection <[EMAIL PROTECTED]> wrote:
> > > Can someone please suggest anyway to resolve this?? This is strange.
> >
> > <web-app xmlns=" http://java.sun.com/xml/ns/javaee";>
> > <web-app>
> >
> > Are two different XML elements. The first belongs to an XML namespace,
> > the second doesn't. XSL is namespace-aware, and thus won't match
> > <web-app xmlns="http://java.sun.com/xml/ns/javaee";> when you tell it
> > to match <web-app>, and vice versa.
> >
> > You could match both, but the problem is that the elements you want to
> > insert need to belong to the "proper" namespace too. <web-app
> > xmlns="http://java.sun.com/xml/ns/javaee";> not only says that the
> > 'web-app' element belongs to the " http://java.sun.com/xml/ns/javaee";
> > namespace, it also sets the "default" namespace. This means that all
> > elements enclosed in 'web-app' also belong to this namespace, while
> > the elements you want to insert, coming from another XML file, also
> > belong to some namespace. XSL doesn't do a "textual" insert, but a
> > "namespace-aware" insert in this case.
> >
> > Sorry if the above is confusing. XSL and XML namespaces both have a
> > learning curve to them. --DD
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>



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

Reply via email to