It appears that you have JavaScript disabled. Click here to find out what you're missing on this site.

BitWorking Theories on software development

by Joe Gregorio
::: Thursday, June 27, 2002

System.Xml.XmlDocument and DTD's (The big chase scene)

Wow, Drew dug really deep into this problem and came up with some interesting stuff. Just go and read it 'cause I can't even begin to do it justice.

11:07:28 PM  #  

Slippery Slope

Slippery Slope

Slippery Slope

Slippery Slope

Slippery Slope

What can I say? I need a new thesaurus.

9:35:51 PM  #  

System.Xml.XmlDocument and DTD's (Soon to be a major motion picture)

So .Net has some problems, along with some other tool sets, with following the rules for relative inclusions in DTDs. Drew was of course correct and I was able to create my own XmlResolver to fix the problem. BTW, the code sample in the MSDN article required some re-working for it to function properly. So now I am sure all the DTDs are loading correctly.

Upon further digging I found that there is a flat version of the XHTML 1.1 DTD that does not have the relative include problem. So I changed test.html to be:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11-flat.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Conforming XHTML 1.1 Template</title>
</head>
<body>
</body>
</html>

Note the -flat.dtd. Now I run a very simple program using test.html:

using System.Xml;
using System;
public class _ {
  public static void Main(string[] args) {
    try {
      XmlDocument doc = new XmlDocument();
      doc.Load("test.html");
      XmlNodeReader reader = new XmlNodeReader(doc);
    }
    catch (System.Exception e) {
      Console.WriteLine(e.Message);
    }				
  }
}
And what do I get but the following error:
The 'x' character, hexadecimal value 0x78, cannot be included in a name.
I also get the same error when using the old DTD with the relative inclusion of DTDs fixed by my custom XmlResolver.

I am a beaten man. I will drop back and punt and use XHTML 1.0 Strict, which I tested and it loads just perfectly fine, thank you.

12:06:56 AM  #