Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

How to suppress duplicate xmlns attributes in child nodes?

Thread view: 
david.karr - 08 Mar 2007 19:42 GMT
I'm using JDK 1.4.2 and WebLogic 8.1.4.

I have a situation where we create a blank SOAPMessage object, and
then parse an XML fragment and insert that fragment as the SOAP body.

This works pretty well, but there is one annoyance we see if the root
element of the fragment defines a non-default namespace, and the
elements in the fragment use that prefix.

The problem is that when the SOAPMessage object is marshalled to XML,
that single "xmlns:<prefix>" attribute is present in EVERY element in
the entire XML document. These extra attributes are redundant, as only
the attribute in the root element of the body should be required.

>From what I can see, it's hard to say whether the "fault" lies in the
"Document.importNode()" or "SOAPMessage.writeTo()" methods. In any
case, I don't expect fixes to those methods anytime soon.

At one time, I had actually written a custom method that does what
"Document.importNode()" does, and after some minor experimentation, I
realized my custom code can resolve this, but I don't have this option
in my current framework.

We're getting around this for now with a method using JDOM that
regenerates the document using "suppressNamespaces" (I'm not sure
exactly what JDOM method is being used). That sort of fixes the
problem, but any documents that actually use multiple namespaces might
break with this approach.
Mike Schilling - 09 Mar 2007 06:27 GMT
> I'm using JDK 1.4.2 and WebLogic 8.1.4.
>
[quoted text clipped - 9 lines]
> the entire XML document. These extra attributes are redundant, as only
> the attribute in the root element of the body should be required.

The first question is whether this really matters.  It's suboptimal and
probably annoying, but doesn't affect the functioning of your application,
other than

1. Making the messages less human-readable.
2. Making the process of serializing the message, transmitting it to the
remote service, and parsing it there slightly less efficient

If no human tries to read this message, 1 is unimportant,  And unless you
can measure the effects of 2, it's not worth worrying about.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.