Sometimes when checking certain XML documents using XmlValidatingReader, the following error appears:
System.Xml.Schema.XmlSchemaValidationException: "The 'http://www.w3.org/XML/1998/namespace:lang' attribute is not declared."
The same document sometimes succeeds. I canβt understand why.
My XSD imports the schema as follows:
<xs:schema id="myschemaId" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://mytargetnamespace.com" xmlns="http://mytargetnamespace.com" xmlns:mm="http://mytargetnamespace.com" elementFormDefault="qualified"> <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd" /> ...
And in the XML document, I have the following attributes:
<root xmlns="http://mytargetnamespace.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://mytargetnamespace.com myschema.xsd">
Finally, XmlReaderSettings:
const XmlSchemaValidationFlags validationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation | XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.AllowXmlAttributes;
This is a standalone exe running on .NET 4.0 in Windows 2003.
I noticed that there is a significant pause when he tries to check. Could this be related? It tries to load the actual schema "xml.xsd" and does not succeed?
roufamatic
source share