Truong Hong Thi wrote:
Hi,
I also set its XmlResolver to
null but to no avail.
I am afraid you have to implement your own resolver.
The dtd is on w3c site at http://www.w3.org/TR/SVG11/svgdtd.html. Try
downloading it at
http://www.w3.org/Graphics/SVG/1.1/D...t-20030114.dtd and save
it to your local machine.
To instruct .net to look for the dtd file on local disk, define your
resolver:
public class MyResolver : XmlUrlResolver
{
public override Uri ResolveUri(Uri baseUri, string relativeUri)
{
// you could check for equality instead of ending with
if (relativeUri.ToUpper().EndsWith(".DTD"))
{
return new Uri("relative/absolute path to DTD on local");
}
return base.ResolveUri (baseUri, relativeUri);
}
}
Use the resolver with XmlDocument and/or XmlReader. Example:
XmlDocument doc = new XmlDocument();
doc.XmlResolver = new MyResolver();
doc.Load("sample.svg");
Hope it helps,
Thi
http://thith.blogspot.com
Thanks Truong for your reply.
I will give your suggestion a go once I get into work (although you
will agree that this shouldn't be the only way to do this - something
simpler surely?!).
In fact, encouraged by your reply, I have had just had another look
through the documentation and I think XmlNodeReader might be the most
basic class to use so will try that too.
Good luck with your new blog!
Does anyone else find the XmlTextReader documentation confusing -
here's a little synopsis below. Am I the only one who is confused when
reading it?
XmlTextReader documentation ...
First of all it says:
1. "XmlTextReader checks the DTD for well-formedness, but does not
validate using the DTD."
then it says:
2. "DTD processing is enabled by default. ... Set the ProhibitDtd
property to true to disable DTD processing." (This is new in 2.0.)
then it says:
3. "XML data can include references to external resources such as a DTD
file. By default external resources are resolved using an
XmlUrlResolver object."
then it says:
4. "Do not allow the XmlReader to open any external resources by
setting the XmlResolver property to a null reference."
So I thought if it wasn't going to use the DTD (point 1) then it
shouldn't need to use its XmlUrlResolver to go and get it. So why does
it?
Point 2 seems to suggest that there is a difference between processing
a DTD and actually using it to validate something: well what's the
point in processing it if it's not going to be using it to validate
something?!
Point 3 is fair enough but point 4 is not true; the request is still
made for the DTD.
Moan over.
Emma