... 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. [BitWorking]
Interesting stuff. Here's the callstack leading up to the exception:
system.xml.dll!System.Xml.XmlTextReader::AddDefaultAttribute(System.Xml.Schema.SchemaAttDef attdef = {System.Xml.Schema.SchemaAttDef}) + 0x5d5 bytes
> system.xml.dll!System.Xml.XmlValidatingReader::AddDefaultAttribute(System.Xml.Schema.SchemaAttDef attdef = {System.Xml.Schema.SchemaAttDef}) + 0x1c bytes
system.xml.dll!System.Xml.Schema.Validator::Validate(System.Xml.ValidationType valType = None) + 0x3f7 bytes
system.xml.dll!System.Xml.XmlValidatingReader::ReadWithCollectTextToken() + 0x298 bytes
system.xml.dll!System.Xml.XmlValidatingReader::Read() + 0x2c bytes
system.xml.dll!System.Xml.XmlLoader::LoadCurrentNode() + 0xce bytes
system.xml.dll!System.Xml.XmlLoader::LoadChildren(System.Xml.XmlNode parent = {System.Xml.XmlElement}) + 0x3e bytes
system.xml.dll!System.Xml.XmlLoader::LoadElementNode() + 0xd2 bytes
system.xml.dll!System.Xml.XmlLoader::LoadCurrentNode() + 0x3d bytes
system.xml.dll!System.Xml.XmlLoader::LoadCurrentNode() + 0xf3 bytes
system.xml.dll!System.Xml.XmlLoader::LoadDocSequence(System.Xml.XmlDocument parentDoc = {System.Xml.XmlDocument}) + 0x47 bytes
system.xml.dll!System.Xml.XmlLoader::Load(System.Xml.XmlDocument doc = {System.Xml.XmlDocument}, System.Xml.XmlReader reader = {System.Xml.XmlValidatingReader}, bool preserveWhitespace = false) + 0xdc bytes
system.xml.dll!System.Xml.XmlDocument::Load(System.Xml.XmlReader reader = {System.Xml.XmlValidatingReader}) + 0x69 bytes
system.xml.dll!System.Xml.XmlDocument::LoadXml(String* xml = "<?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>") + 0x6d bytes
I've pinpointed the problem to this section of code within XmlNSAttributeTokenInfo::FixNSNames method.
<codeSnippet language="CIL">
IL_0129: ldc.i4.0
IL_012a: callvirt instance char [mscorlib]System.String::get_Chars(int32)
IL_012f: call bool System.Xml.XmlCharType::IsLetter(char)
IL_0134: brtrue.s IL_0152
IL_0136: ldstr "Xml_BadNameChar"
IL_013b: ldarg.0
IL_013c: ldfld string System.Xml.XmlNSAttributeTokenInfo::_Name
IL_0141: ldc.i4.0
IL_0142: callvirt instance char [mscorlib]System.String::get_Chars(int32)
IL_0147: call string[] System.Xml.XmlException::BuildCharExceptionStr(char)
IL_014c: newobj instance void System.Xml.XmlException::.ctor(string,
string[])
IL_0151: throw
</codeSnippet>
Now, the first thing I tried was adding an explicit namespace and guess what? It works! If you named the namespace and prefix all of your elements with the namespace name, the validation succeeds. For example, this works:
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11-flat.dtd">
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xhtml:head>
<xhtml:title>Conforming XHTML 1.1 Template</xhtml:title>
</xhtml:head>
<xhtml:body>
</xhtml:body>
</xhtml:html>
Obviously this shouldn't be required, but maybe it will help you in the meantime. A temporary solution would be to pass all your XHTML 1.1 docs through an XSLT that looks for a default namespace declartion, change it to be a named namespace and prefix self/descendant elements (without an explicit namespace) with the name.
Now onto the real problem: it seems that the Schema.Validate method attempts to add a namespace attribute to any node that does not contain an explicit namespace declaration as it validates each node using XmlTextReader::AddDefaultAttribute. For whatever reason, XmlNSAttributeTokenInfo::FixNSNames is barfing on the validation of this added attribute claiming to only have found 'x'.
If I find any more details, I will post a follow up, but this certainly seems to be some sort of bug within the schema validation classes. I have a sneaking suspicion this is related to DTD only validated documents because I know I've used default namespaces successfully in XML Schema validated documents in the past.