Microsoft KB Archive/317611

= BUG: Type &quot;###&quot; is not declared in reference to local type of an included XSD Schema file =

Article ID: 317611

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft .NET Framework Class Libraries 1.0
 * Microsoft .NET Framework Class Libraries 1.1
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition

-



This article was previously published under Q317611



SYMPTOMS
The current implementation of XSD schema-validation support in the .NET framework does not convert the targerNamespace of the local referencing type of an included XSD (it does not support the &quot;chameleon&quot; include). For example, the following a.xsd file includes the b.xsd and c.xsd files: 

   Inside b.xsd, a testType type is defined:        Inside c.xsd, test is declared with the testType type:    The following error message is returned with the a.xsd schema file:

&quot;Type 'testType' is not declared.&quot; in c.xsd

<div class="resolution_section">

RESOLUTION
To work around this problem, add a xmlns=&quot;test&quot; namespace declaration to the c.xsd file, for example:  <xsd:element name=&quot;test&quot; type=&quot;testType&quot; xmlns=&quot;test&quot;/> </xsd:schema>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Steps to Reproduce the Problem
<ol> <li>Save the preceding a.xsd file in the c:\temp folder. Save the b.xsd and c.xsd files under the same folder as a.xsd.</li> <li>Create a C# console Project.</li> <li> Replace the code the is inside the Class1.cs file with following code: using System; using System.IO; using System.Xml; using System.Xml.Schema;

namespace ValidationTest {   class Sample {       public static void Main {           try {               XmlSchemaCollection sc = new XmlSchemaCollection; sc.Add(&quot;test&quot;, &quot;c:\\temp\\a.xsd&quot;); Console.WriteLine(&quot;No Schema error.&quot;); }           catch(XmlSchemaException ex) {               Console.WriteLine(&quot;XSD schema Error: {0}&quot;, ex.Message); }           Console.Read; }   } }                    </li> <li>Compile and then run the project. In the console window, the following error message is returned:

XSD schema Error: Type 'test' is not declared. An error occurred at file:///c:/temp/c.xsd(2, 3).

</li> <li> Open the c.xsd file, and then add xmlns=&quot;test&quot; to the xsd:element, for example: <xsd:element name=&quot;test&quot; type=&quot;test&quot; xmlns=&quot;test&quot;/> </li> <li>Compile and then run the project. In the console window, the following output is returned:

No Schema error.

</li></ol>

Keywords: kbvs2002sp1sweep kbbug kbenv KB317611

-

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

© Microsoft Corporation. All rights reserved.