Hi, I need some help...
Im trying to use XmlValidatingParser with a custom XmlResolver. Im
finding, however, that the custom resolver never gets called, and that
the XmlValidatingParser acts as a non-validating parser
I created a custom resolver called XmlBreakingResolver, whos GetEntity
and ResolveUri methods have breakpoints set in them along with
Debug.Assert(false). The breakpoints are never reached, and the the
Asserts never throw.
I know my data is good because, when I load the schema into the
Schemas property of the ValidatingReader instead of trying to use the
XmlResolver, all seems to work properly.
Searching on the web, I found a few references to XmlResolvers not
being called, but no solutions. has anyone struck this problem, and/or
can anyone suggest a solution...
Any help greatly appreciated...
Heres my code:
XmlValidatingReader vr = new XmlValidatingReader(new
XmlTextReader(input));
vr.XmlResolver = new XmlBreakingResolver();;
vr.Namespaces = true;
vr.ValidationType = ValidationType.Schema;
Console.WriteLine("------------------");
while (vr.Read())
{
XmlSchemaType type = vr.SchemaType as XmlSchemaType;
Console.WriteLine("{0} {1} {2}", vr.NodeType, vr.Name, type !=
null ? ":"+type.Name : "");
}
Console.WriteLine("------------------");
heres my data:
================== schema http://ReflectionXmlSerializer/1/1
==================
<?xml version="1.0" encoding="IBM437"?>
<xs:schema
xmlns:tns="http://ReflectionXmlSerializer/1/1"
elementFormDefault="qualified"
targetNamespace="http://ReflectionXmlSerializer/1/1"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="T" nillable="true" type="tns:T" />
<xs:complexType name="T">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="x" type="xs:int"
/>
<xs:element minOccurs="1" maxOccurs="1" name="y" type="xs:int"
/>
<xs:element minOccurs="1" maxOccurs="1" name="z" type="xs:int"
/>
<xs:element minOccurs="0" maxOccurs="1" name="b" type="tns:B" />
<xs:element minOccurs="0" maxOccurs="1" name="s"
type="tns:ArrayOfString"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="B">
<xs:sequence>
<xs:element minOccurs="1" maxOccurs="1" name="g"
type="xs:double" />
</xs:sequence>
<xs:attribute name="f" type="xs:float" use="required" />
</xs:complexType>
<xs:complexType name="ArrayOfString">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="string"
nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
================== instance xml
<?xml version="1.0" encoding="IBM437"?>
<T xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ReflectionXmlSerializer/1/1">
<x>1335274566</x>
<y>1639139984</y>
<z>480098254</z>
<b f="0.8403818">
<g>0.21079391902815267</g>
</b>
<s>
<string>1710934067</string>
<string>137379920</string>
<string>1794435757</string>
</s>
</T>
Heres My resolver:
class XmlBreakingResolver : XmlResolver
{
System.Net.ICredentials _credentials = null;
public override System.Net.ICredentials Credentials
{
set { this._credentials = value; }
}
public override object GetEntity(Uri uri, string role, Type type)
{
Debug.Assert(false);
return null;
}
public override Uri ResolveUri(Uri uri, string relative)
{
Debug.Assert(false);
return base.ResolveUri(uri, relative);
}
}