[xsl] Keeping doctype declaration in resulting output [XSLT 1.0]

Subject: [xsl] Keeping doctype declaration in resulting output [XSLT 1.0]
From: pankaj.c@xxxxxxxxxxxxxxxxxx
Date: Tue, 5 Oct 2010 15:39:39 +0530
Hi all,

CDATA is not part of the input tree that is passed to the xslt processor 
and understood that to keep CDATA in certain elements use:

<xsl:output cdata-section-elements="element"/>
<xsl:template match="element">
        <xsl:copy>
          <xsl:text 
disable-output-escaping="yes">&lt;![CDATA[</xsl:text><xsl:value-of 
select="text()" disable-output-escaping="yes" /><xsl:text 
disable-output-escaping="yes">]]&gt;</xsl:text>
        </xsl:copy>
</xsl:template>

But what about keeping the DTD declaration along with Entity in resulting 
output (required for roundtriping). 

<!DOCTYPE chapter PUBLIC "-//ABC//DTD version 1.1.1//XML" "book111.dtd" 
[<!ENTITY fx1 SYSTEM "fx1" NDATA IMAGE><!ENTITY gr1 SYSTEM "gr1" NDATA 
IMAGE>]>

I remember attempting this way back with "doctype-public" /(Karen Lease's 
example at XML Europe)  but with no good results. Anybody got a luck for 
that or better way to get this done in XSLT.  Currently I am ending up 
using Java (TransformerFactory, DOMSource etc) after transformation to get 
this done. 

Any thoughts will be appreciated.

Best,
Pankaj 

Current Thread