aspose file tools*
The moose likes XML and Related Technologies and the fly likes Removing namespace prefixes from attributes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Removing namespace prefixes from attributes" Watch "Removing namespace prefixes from attributes" New topic
Author

Removing namespace prefixes from attributes

Martin Fiskare
Greenhorn

Joined: Jun 24, 2010
Posts: 7
Hi there!

I need to export data using JAXB into XML. A 3rd party application, that needs to import the file can't handle namespace prefixes, no idea why but they keep insisting that there's no workaround possible on their side.

My question is now, is there any way to remove them prefixes from, most important, the root element, and if possible from the attributes of the subelements? See example below



Any suggestions are highly appreciated.

Thank you in advance.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18986
    
    8

Have you considered the possibility that they can't process your document because it is not well-formed? It has namespace prefixes without a corresponding namespace declaration.

If the answer is that you posted an incomplete version of the document and your real document is well-formed, then I would suggest doing an XSL transformation to produce a similar document without namespaces.
Martin Fiskare
Greenhorn

Joined: Jun 24, 2010
Posts: 7
Yes, what i did in the first place was to run a namespace-filter, that removed the namepace attribute from the root element, resulting in every attibute of the sub-elements having a prefix 'ns1'.... and it's not well-formed anymore of course... DARN!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Removing namespace prefixes from attributes