You don't need to do anything special to create the document with Namespace declarations. If the DOM tree has a node with a reference to a namespace, when you persist the tree to an XML file( using transformation ) the namespace should appear in the XML file. If it doesn't then you have a problem in the code.
Perhaps more specific information about your problem will help!
------------------
Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.