Wrting an XML file setting multiple namespaces

N

neroblu80

Hello everybody,

Im trying to write an XML file through JDOM.
My problem is that in the root of the file i need to add three
namespaces to obtain something like:

<root xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance" xmlns="http://www.w3.org/2001/
XMLSchema">

I've been able to use root.setNamespace(ns) to insert the attribture
xmlns
but i cant find any way to insert others ns with their prefixes. Is
there any method that I dont know? In various docs I didnt find
anything and if i try to use root.setAttribute("xmlns:xsi","value") I
get a format error for the attribute.

Does anyone can help me??
Thank you!
 
T

Tajonis

You should look at using element.addNamespaceDeclaration(Namespace)
instead of element.setNamespace(Namespace). By using
element.addNamespaceDeclaration(Namespace) you will add to the
element's List additionalNamespaces field instead of setting the
element's namespace field. Have a look at <a href="http://www.jdom.org/
docs/apidocs/org/jdom/Element.html">Element JavaDoc</a>
 
T

Tajonis

You should look at using element.addNamespaceDeclaration(Namespace)
instead of element.setNamespace(Namespace). By using
element.addNamespaceDeclaration(Namespace) you will add to the
element's List additionalNamespaces field instead of setting the
element's namespace field. Have a look at <a href="http://www.jdom.org/
docs/apidocs/org/jdom/Element.html">Element JavaDoc</a>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top