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.

Wrting an XML file setting multiple namespaces

Thread view: 
neroblu80 - 27 Mar 2007 16:31 GMT
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>


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.