How do I set the DTD of the freshly constructed XML documents to use this one in order to be able to check the correctness of the documents at a later time?
Your method of getting the DTD object is correct. However, we do not do any validation while creating the DOM tree using DOM APIs. So setting the DTD in the document will not help validate the DOM tree that is constructed. The only way to validate an XML file is to parse the XML document using the DOM parser or the SAX parser.