If you do an internet search for anything that will generate a DTD from an XML file, you will get a whole raft of different editors and utilities.
The most interesting thing is that if you have ubuntu then you probably already have a command line utility that will do the same:
mkdtdskel inputfile > outputfile
I imagine this stands for "make a DTD skeleton".
Amazingly you DON'T get a reference anywhere in the internet search engine for this utility! Strange because it is extremely fast and already installed with the distro.
If you need to do this type of thing try out out.