I’m trying to load a xslt transformation in .NET 2.0 . I’m taking in an XML Document already in memory, as it’s dynamically generated before hand. When I use the XMLReader option with ProhibitDTD=false , I get an error saying that I need to enable scripts in the XsltSettings. If I use the Load method with XsltSettings (Trusted), I get the DTD error. Any thoughts on how to apply both ProhibitDTD=false AND EnableScript=true ?
public static string ConvertXML(XmlDocument InputXMLDocument, string XSLTFilePath, XsltArgumentList XSLTArgs)
{
StringWriter sw = new System.IO.StringWriter();
XslCompiledTransform xslTrans = new XslCompiledTransform();
XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
XmlReader reader = XmlReader.Create(XSLTFilePath, settings);
try
{
//xslTrans.Load(reader);
xslTrans.Load(XSLTFilePath, XsltSettings.TrustedXslt, new XmlUrlResolver());
xslTrans.Transform(InputXMLDocument.CreateNavigator(), XSLTArgs, sw);
return sw.ToString();
}
I got it – there was an overloaded method that didn’t seem too obvious with the proper types, but it works.