Q:

How to allow DTD in XML Documents loaded via XSLT's document(uri) function with XslCompiledTransform (.NET)

When the document(uri) function is used to load another document within the XSLT, where the target document contains a DTD I get an XslTransformException, containing an inner XmlException:

For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method. 

As the XmlReader is created within the XSLT implementation there is no direct way to create the XmlReader with the settings I want, and none of the XslCompiledTransform, XmlResolver1 or related classes seem to provide any form of hook.
(I'm using a DTD to set some HTML entities to make the authoring of the document easier.)
1 based on looking at XmlUrlResolver in Reflector this just loaded the URI's target as a Stream.
E.g. is the XSLT contains
<xsl:apply-templates select="document('more.xml')/root"/>

and more.xml contains a DTD then the exception above is the result.

A:

The same XmlResolver you pass to the Transform method is used for document function, this resolver can return an XmlReader that allows DTD, instead of returning Stream. You can also return IXPathNavigable. In other words, you need a specialized implementation of XmlResolver to fix this issue.

