When a function is document(uri)used to load another document into XSLT, where the target document contains a DTD, I get XslTransformExceptionthat contains an internal one XmlException:
For security reasons, DTD is not permitted in this XML document. To enable DTD processing, set the ProhibitDtd property to XmlReaderSettings false and pass the settings to the XmlReader.Create method.
Since XmlReaderestablished in XSLT implementation, there is no direct way to create an XmlReader with the desired settings, and none XslCompiledTransform, XmlResolver 1 or related classes seem to provide any form of hook.
(I use DTD to set some HTML objects to make document creation easier.)
1 Based on a view XmlUrlResolverin Reflector, it simply loaded the target URI as a stream.
eg. XSLT contains
<xsl:apply-templates select="document('more.xml')/root"/>
and more.xmlcontains a DTD, then the above exception is the result.
source
share