Hi Nate,

Which JVM and Ant version are you using ?

If I do this:

     <xmltask source="a.xml" dest="b.xml" report="true" failWithoutMatch="true">
     <insert path="/:portlet-app/:portlet/:portlet-name"
             position="before">
            <![CDATA[<description xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
                      xml:lang="${lang}">${portlet.description}</description>]]>
      </insert>
   </xmltask>

(which looks like what you have below), then I get:

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
  <portlet>
   <description xml:lang="${lang}">${portlet.description}</description>
<portlet-name>SomePortlet</portlet-name>
  </portlet>
</portlet-app>

which looks like what you want. I'm running Ant 1.6.3 and JDK 1.5.0_05.

Can you confirm if the above does/doesn't do what you want ? Thx.

Brian

ps. namespaces are a real pain to deal with - with or without XmlTask. I'm wondering if XmlTask could provide namespace-specific functions. Answers on a postcard...

Nate Pahucki wrote:
Hello all, I hope someone can help with this. 

I have a document with a namespace in a buffer, I try to add some nodes
to it with the insert sub-task of xmltask, but when the document is
later written, the nodes I inserted have an attribute of xmlns="" which
seems to explicitly declare NO namespace. I don't want the xmlns to show
up at all, resulting in the nodes I inserted having the same namespace
as the parent node. 

The source document (one in the buffer) looks something like: 

<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
  <portlet>
   <portlet-name>SomePortlet</portlet-name>
   .....
</portlet>
</portlet-app>

Here is the code snippet that does the insert:

          <xmltask sourcebuffer="${frag_tmp}" destbuffer="${frag_tmp}"
failWithoutMatch="true" report="false">
                <insert path="/:portlet-app/:portlet/:portlet-name"
position="before">
                    <![CDATA[<description
xml:lang="${lang}">${portlet.description}</description>]]>
                </insert>
            </xmltask>

This produces: 

<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
  <portlet>
  <description xmlns="" xml:lang="xx">Some Description</description> 
  <portlet-name>SomePortlet</portlet-name>
   .....
</portlet>
</portlet-app>

I also tried inserting an xmlns attribute explicitly matching the
parent document like this: 

                <insert path="/:portlet-app/:portlet/:portlet-name"
position="before">
                    <![CDATA[<description
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xml:lang="${lang}">${portlet.description}</description>]]>
                </insert>

but then I end up with this, which fails validation:

<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
  <portlet>
  <description
__NS1:xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
xmlns:__NS1="http://www.w3.org/2000/xmlns/" xml:lang="xx">Some
Description</description> 
  <portlet-name>SomePortlet</portlet-name>
   .....
</portlet>
</portlet-app>


Is there some trick to getting the text nodes that I insert to assume
the parent node's namespace?

Thank you in advance for any ideas. 




-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Xmltask-users mailing list
Xmltask-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xmltask-users
  

-- 
Brian Agnew                  http://www.oopsconsultancy.com
OOPS Consultancy Ltd         brian @ oopsconsultancy.com
Tel: +44 (0)7720 397526
Fax: +44 (0)20 8682 0012

Reply via email to