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!
Tajonis - 27 Mar 2007 17:04 GMT
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>
Tajonis - 27 Mar 2007 17:48 GMT
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>