Microsoft KB Archive/325695

= Error message when you view multi-dimensional XSD schemas in the Visual Studio .NET XML Schema Designer =

Article ID: 325695

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual Studio 2005 Standard Edition
 * Microsoft Visual Studio 2005 Professional Edition
 * Microsoft Visual Studio 2005 Express Edition
 * Microsoft Visual Studio .NET 2003 Professional Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Enterprise Architect

-



This article was previously published under Q325695



SYMPTOMS
When you try to open and view a multi-dimensional XML Schema Definition (XSD) schema in Visual Studio .NET, an XML Designer window may open instead of a Schema Designer window, and you may receive the following error message in the Data view of the XML Designer:

Although this XML document is well formed, it contains structure that the DataView cannot display. The same table cannot be the child table in two nested relations



CAUSE
The XSD schema is saved as a file with an .xml extension. The Visual Studio .NET designers are extension-based. Files with an .xml extension are interpreted as regular XML files, so an XML Designer window opens instead of a Schema Designer window when you try to open and view the document in Visual Studio .NET. The XML Designer in Visual Studio .NET uses the ADO.NET schema inference rules to automatically infer the schema of an XML document. The ADO.NET schema inference rules do not permit or support multi-dimensional relationships in the RTM release of the Microsoft .NET Framework.



RESOLUTION
Rename or save the document as a file with an .xsd extension to open and view it in a Visual Studio .NET XML Schema Designer window. The Visual Studio .NET XML Schema Designer can correctly load and display multi-dimensional XSD schemas.



STATUS
This behavior is by design.



MORE INFORMATION
To re-create the error message and test the resolution, follow these steps:   In Notepad, paste the following code in a new file:           <xs:element name=&quot;OrderId&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;CustomerId&quot; type=&quot;xs:string&quot; /> <xs:element name=&quot;Item&quot; type=&quot;ItemType&quot; maxOccurs=&quot;unbounded&quot; /> </xs:sequence> </xs:complexType>   <xs:element name=&quot;Item&quot; type=&quot;ItemType&quot; maxOccurs=&quot;unbounded&quot; /> </xs:sequence> </xs:complexType>   <xs:element name=&quot;Order&quot; type=&quot;OrderType&quot; maxOccurs=&quot;unbounded&quot; /> <xs:element name=&quot;Inventory&quot; type=&quot;InventoryType&quot; maxOccurs=&quot;unbounded&quot;/> </xs:sequence> </xs:complexType> </xs:schema> </li> <li>Save the file as OrderInventory.xml to your hard disk. The sample schema is multi-dimensional because both the Order and the Inventory child elements of the OrdersInventoryData element have a child element named Item of ItemType complexType (the Item element is a child in two parent-child relationships).</li> <li>In Visual Studio .NET, open a new or existing Microsoft Visual Basic .NET or Microsoft Visual C# .NET project, such as a Windows Application project or a Console Application project.</li> <li>Add the OrderInventory.xml XML document that you just created to the project.</li> <li>In Solution Explorer, double-click to open OrderInventory.xml. An XML view of the contents of the document is displayed in an XML Designer window.</li> <li>Switch to the Data view of the XML Designer window. You receive the following error message:

Although this XML document is well formed, it contains structure that the DataView cannot display. The same table (Item) cannot be the child table in two nested relations

The .xml file name extension causes an XML Designer window to be opened instead of a Schema designer window. The contents of the file are therefore treated as regular XML instead of as an XSD schema. When a Visual Studio .NET XML Designer window is opened to display XML data, the ADO.NET schema inference rules are applied to determine the schema structure of the XML document. From the ADO.NET schema inference perspective, a complexType XML element is inferred as an independent table, and one table cannot be a child table in two or more parent-child relationships. In the sample schema, the Item element of the ItemType complexType has been defined to be a child of the Order (OrderType complexType) and Inventory (InventoryType complexType) elements. This is not permitted or supported by the ADO.NET schema inference rules in the RTM release of the Microsoft .NET Framework.</li> <li>Close the XML Designer window.</li> <li>In Solution Explorer, rename OrderInventory.xml to OrderInventory.xsd. To do this, right-click the file, and then click Rename.</li> <li>In Solution Explorer, double-click to open OrderInventory.xsd. An XML view of the contents of the document is displayed in an XML Schema Designer window. Switch to the Schema view and notice that the schema structures are displayed correctly.</li></ol>

<div class="references_section">