See below. Nate Pahucki wrote: I need to look at this in more depth, but there's no 'namespace' specific operations in XmlTask. One scenario where it may stuff up is copying a document fragment from a document with namespace A and inserting into a document with namespace B. I fear XmlTask can't do this currently.Update on this: >From playing around a bit more, it seems the following holds true: 1) Just adding an xmlns attribute to a node does not make it belong to that namespace (how does one set the namespace on inserted nodes then)?. Confirmed at my end. The 'simple' formatter is lifted from some third party code, and I confess I'm not au fait with it. So I will need to investigate further.2) Using an existing document with a namespace declaration, and doing nothing more than writing it out using the outputter="simple" adds a few superfluous namespace declarations, for example _NS1: __NS1:. Agreed again.3) Not using the outputter="simple" solves my original problem (the unwanted presence of xmlns="" on any node I insert using the text body of the insert sub-task), but makes the output hard to read as the inserted nodes are not indented. Not unreasonable.So, is this a bug in in the 'simple' outputter? Is there a way to have my cake and eat it too? I want properly behaving namespaces AND a well formatted document. Brian Thanks again.--------------------- 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 |
- [Xmltask-users] RE:Problem with namespaces in output document... Nate Pahucki
- Re: [Xmltask-users] RE:Problem with namespaces in output... Brian Agnew