Microsoft KB Archive/317353

= FIX: Unexpected Validation Error on xsd:any processContents=&quot;skip&quot; =

Article ID: 317353

Article Last Modified on 9/18/2003

-

APPLIES TO


 * Microsoft .NET Framework 1.0

-



This article was previously published under Q317353



SYMPTOMS
If you define a complex type with a xsd:any declaration and an attribute of processContents=&quot;skip&quot;; for example          When you use an XmlValidatingReader(System.Xml namespace) call to validate the following XML data against the above schema  the following error is returned:

Severity:Warning Message : Could not find schema information for the element 'this'. An error occurred at (x, y).

Severity:Error Message : The 'that' attribute is not declared. An error occurred at (x, y).



STATUS
This bug was corrected in Microsoft .NET Framework Class Libraries. However, a similar problem where you may have xsi or xsd attributes continues to occur. This problem is also a bug and is not fixed in the .NET Framework Class Libraries 1.1.



Steps to Reproduce Behavior
  Save the following XML data as test.xml on drive C:  <this that=&quot;somevalue&quot;/> Save the following XSD schema as test.xsd on drive C: <xsd:schema id=&quot;test1&quot; xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;> <xsd:element name=&quot;root&quot;>   <xsd:any namespace=&quot;##any&quot; processContents=&quot;skip&quot; /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </li> <li> Create a Microsoft C# Console Application. Replace the code in Class1.cs with the following: using System; using System.Xml; using System.Xml.Schema; using System.IO;

namespace Test {   ///     /// Summary description for Class1. ///    class Class1 {       ///         /// The main entry point for the application. ///        [STAThread] static void Main(string[] args) {           Class1 cls= new Class1; cls.validateXml; }       public void validateXml {           //Hard-coded path doesn't work either. FileStream stream = new FileStream(&quot;c:\\test.xml&quot;, FileMode.Open); try {               XmlValidatingReader reader= new XmlValidatingReader(stream, XmlNodeType.Document, null); //Set the schema type as XSD schema. reader.ValidationType = ValidationType.Schema;

//Add the XSD to reader's schema collection. XmlSchemaCollection schemaCollection = reader.Schemas; schemaCollection.Add(&quot;&quot;,&quot;c:\\test.xsd&quot;); //Set the event handler. reader.ValidationEventHandler += new ValidationEventHandler (ValidationHandler);

while(reader.Read); System.Console.WriteLine(&quot;Validation finished&quot;); }           catch(XmlException ex) {               System.Console.WriteLine(&quot;XmlException : {0}&quot;, ex.ToString); }                       System.Console.Read; }       public static void ValidationHandler(object sender, ValidationEventArgs args) {           System.Console.WriteLine( &quot;***Validation error Severity:{0} Message : {1}&quot;, args.Severity, args.Message); }   } }                    </li> <li>Compile and then run the application. In the console window, the following error is returned:

Severity:Warning Message : Could not find schema information for the element 'this'. An error occurred at (1, 8).

Severity:Error Message : The 'that' attribute is not declared. An error occurred at (1, 12).

</li></ol>

Keywords: kbbug kbnofix KB317353

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.