Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Jaxp-Unable to remove an attribute permanently from document object

843834Dec 10 2003 — edited May 12 2004
Hi

I have a requirement where I have to strip out an attribute called "xmlns" at the root element of my xml document.

for eg: <UserProfile xmlns="http://foo">
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>

I tried using API's
1) document.getDocumentElement.removeAttribute("xmlns")

After this my xml document look like this

<UserProfile >
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>

Also tried this..
2) Attr att=document.getDocumentElement().getAttributeNode("xmlns");
att.setValue("");
document.getDocumentElement().setAttributeNodeNS(att);

After this my xml document look like this

<UserProfile xmlns="">
<ID>1234</ID>
<Name>Bob</Name>
</UserProfile>

Irrespective of all this , when I gave the new xml document to Jaxb for processing , Jaxb complains that
unexpected root element

uri:http://foo

Though this attribute neither visible nor accessible using any DOM apis, still this attribute exists as part of this document.

Could somebody explains a little more about this behaviour or help me to resolve this..

Any feedback will be deeply appreciated,

Ranjith Pillai.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 9 2004
Added on Dec 10 2003
13 comments
521 views