Unfortunately there's no way in standard XSLT to generate an internal DTD like the one you describe, without using the horrible disable-output-escaping mechanism (you can do it in Saxon using the saxon:doctype extension, but that doesn't help all that much - it has the same architectural problems).
There's no reason why the text that you generate has to be fixed, you can compute it using xsl:value-of in the same way as any other text.
However, there's no obvious way of reading it from the source document, unless you are prepared to use XSLT 2.0's unparsed-text() function to read the document in unparsed form and extract the DOCTYPE definition "by hand".
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference