Generally in order to write a transformation, you need
to know the structure of the target document you are trying to produce. The new
DTD needs to exist, at least in your head, before you can write the
transformation. Producing a transformation whose results always conform to this
DTD is a question of doing correct coding, there are no tools to help you;
unless you use one of the graphical XSLT-builders which only really work for
rather trivial transformations.
How obtain an update DTD when I transform one xml into another
xml using xslt?