EDN Admin
Well-known member
Im writing a small utility like msxsl.exe (that performs bad on Windows 7 / Windows Server 2008).
I see similar threads but they are all older and ends up with the advice "settings.ProhibitDtd =
<span style="color:#0000ff; font-size:small False" which is now (.NET 4.5) deprecated:
<pre class="prettyprint XslCompiledTransform xslt = new XslCompiledTransform();
XmlSecureResolver myResolver = new XmlSecureResolver(new XmlUrlResolver(), secureDir );
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.ConformanceLevel = ConformanceLevel.Fragment;
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create(styleSheet, readerSettings);
XsltSettings xsltSettings = new XsltSettings();
xsltSettings.EnableDocumentFunction = true;
xsltSettings.EnableScript = true;
xslt.Load(reader, xsltSettings, myResolver);
string outputFileTemp = secureDir+@"temp.xml";
using (XmlWriter w = XmlWriter.Create(secureDir + @"temp.xml", xmlSettings))
{
// Transform the file.
xslt.Transform(inputFile, xslArg, w);
}[/code]
I applied XmlReaderSettings to a XmlReader and supplied this in the Load call. However I keep getting the exception
For security reasons DTD is prohibited in this XML document. To enable DTD proce<br/>
ssing set the DtdProcessing property on XmlReaderSettings to Parse and pass the<br/>
settings into XmlReader.Create method.
My XML document (which I cannot change) contains
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE pdf2xml SYSTEM "pdf2xml.dtd
<hr class="sig Jorgen
View the full article
I see similar threads but they are all older and ends up with the advice "settings.ProhibitDtd =
<span style="color:#0000ff; font-size:small False" which is now (.NET 4.5) deprecated:
<pre class="prettyprint XslCompiledTransform xslt = new XslCompiledTransform();
XmlSecureResolver myResolver = new XmlSecureResolver(new XmlUrlResolver(), secureDir );
XmlWriterSettings xmlSettings = new XmlWriterSettings();
xmlSettings.ConformanceLevel = ConformanceLevel.Fragment;
XmlReaderSettings readerSettings = new XmlReaderSettings();
readerSettings.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create(styleSheet, readerSettings);
XsltSettings xsltSettings = new XsltSettings();
xsltSettings.EnableDocumentFunction = true;
xsltSettings.EnableScript = true;
xslt.Load(reader, xsltSettings, myResolver);
string outputFileTemp = secureDir+@"temp.xml";
using (XmlWriter w = XmlWriter.Create(secureDir + @"temp.xml", xmlSettings))
{
// Transform the file.
xslt.Transform(inputFile, xslArg, w);
}[/code]
I applied XmlReaderSettings to a XmlReader and supplied this in the Load call. However I keep getting the exception
For security reasons DTD is prohibited in this XML document. To enable DTD proce<br/>
ssing set the DtdProcessing property on XmlReaderSettings to Parse and pass the<br/>
settings into XmlReader.Create method.
My XML document (which I cannot change) contains
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE pdf2xml SYSTEM "pdf2xml.dtd
<hr class="sig Jorgen
View the full article