Hi,
I am trying to validate an XML file using the XmlValidatingReader and
XmlUrlResolver.
The code for which goes like this:
// Read the XML file.
XmlTextReader xmlReader = new XmlTextReader( _PathToXMLDoc);
XmlValidatingReader valReader = new XmlValidatingReader(xmlReader);
valReader.ValidationType = ValidationType.Schema;
XmlResolver xRes = new XmlUrlResolver();
valReader.XmlResolver = xRes;
valReader.ValidationEventHandler += new
ValidationEventHandler(this.ValidationCallBack);
while(valReader.Read())
{
}
I have the XML document which refers to a xsd file located on a directory
on the local workstation.
If my XML document has the attribute:
xsi:schemaLocation="20040518 C:\Inetpub\wwwroot\20040518.xsd">
then the validation suceeds.
But if I were to change the attribute to:
xsi:schemaLocation="20040518 http://localhost/20040518.xsd";>
I get the error:
"Cannot load schema for the namespace '20040518' - Specified argument was
out of the range of valid values.
Parameter name: The specified value must be greater than 0."
I am able to view the XSD file in IE using the URL
http://localhost/20040518.xsd, hence I know that the XSD file is present and
the IIS is configured correctly.
Any ideas as what's causing this error?