FIX: You receive an unexpected validation error message when you define a complex type with an "xsd:any" element declaration and an attribute of processContents="skip" in the .NET Framework 1.1 (890945)



The information in this article applies to:

  • Microsoft .NET Framework 1.1

SYMPTOMS

In the Microsoft .NET Framework 1.1, you may define a complex type with an xsd:any element declaration and an attribute of processContents="skip" that is similar to the following code sample.
<xsd:schema id="test1" xmlns:xsd="http://www.proseware.org/2001/XMLSchema">
	<xsd:element name="root">
	    <xsd:complexType>
		    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
			    <xsd:any namespace="##any" processContents="skip" />
		    </xsd:sequence>
	    </xsd:complexType>
	</xsd:element>
</xsd:schema>
You may also use an XMLValidatingReader method call (in the System.Xml namespace) to validate the following XML data against this schema:
<root xmlns:xsi="http://www.proseware.org/2001/XMLSchema-instance" xmlns:xsd="http://www.proseware.org/2001/XMLSchema">
	<testfield xsi:nil="false">Some value</testfield>
</root>
If you do this, you may receive the following error message:
Severity:Error Message : If the 'nillable' attribute is false in the schema, then the 'xsi:nil' attribute must not be present in the instance. An error occurred at , (x, y).

RESOLUTION

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that this article describes. Apply it only to systems that are experiencing this specific problem.

To resolve this problem, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date         Time   Version        Size       File name
   ---------------------------------------------------------------------
   17-Dec-2004  03:05  1.1.4322.2057    573,440  System.web.services.dll  
   17-Dec-2004  03:05  1.1.4322.2057  1,355,776  System.xml.dll   

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Steps to reproduce the behavior

  1. Save the following XML data as Test.xml.
    <root xmlns:xsi="http://www.proseware.org/2001/XMLSchema-instance" xmlns:xsd="http://www.proseware.org/2001/XMLSchema">
    	<testfield xsi:nil="false">Some value</testfield>
    </root>
    
  2. Save the following XSD schema as Test.xsd in the same folder.
    <xsd:schema id="test1" xmlns:xsd="http://www.proseware.org/2001/XMLSchema">
    	<xsd:element name="root">
    	    <xsd:complexType>
    		    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
    			    <xsd:any namespace="##any" processContents="skip" />
    		    </xsd:sequence>
    	    </xsd:complexType>
    	</xsd:element>
    </xsd:schema>
    
  3. Save the following code sample as Class1.cs in the same folder.
    using System;
    using System.Xml;
    using System.Xml.Schema;
    using System.IO;
    
    namespace Test
    {
    	/// <summary>
    	/// Summary description for Class1.
    	/// </summary>
    	class Class1
    	{
    		/// <summary>
    		/// The main entry point for the application.
    		/// </summary>
    		[STAThread]
    		static void Main(string[] args)
    		{
    			Class1 cls= new Class1();
    			cls.validateXml();
    		}
    		public void validateXml()
    		{
    			//The hard-coded path does not work either.
    			FileStream stream = new FileStream("test.xml", 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 the schema collection of the reader.
    				XmlSchemaCollection schemaCollection = reader.Schemas;
    				schemaCollection.Add("","test.xsd");
    
    				//Set the event handler.
    				reader.ValidationEventHandler += new ValidationEventHandler (ValidationHandler);
    
    				while(reader.Read());
    				System.Console.WriteLine("Validation finished.");
    			}
    			catch(XmlException ex)
    			{
    				System.Console.WriteLine("XmlException : {0}", ex.ToString());
    			}
                            System.Console.Read();
    		}
    		public static void ValidationHandler(object sender, ValidationEventArgs args)
    		{
    			System.Console.WriteLine( "***Validation error Severity:{0} Message : {1}", args.Severity,  args.Message);
    		}
    	}
    }
    
  4. Compile the application by using the following command at the command prompt:

    csc /r:System.Xml.dll Class1.cs

  5. Run the application.

    Note In the console window, you may receive the following error message:
    ***Validation error Severity:
    Error Message : If the 'nillable' attribute is false in the schema, then the 'xsi:nil' attribute must not be present in the instance.
    An error occurred at , (1, 107).
    Validation finished

Modification Type:MajorLast Reviewed:4/7/2006
Keywords:kbQFE KBHotfixServer kbNetFrame110preSP2fix kbfix kbbug KB890945 kbAudDeveloper