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

Article translations Article translations
Article ID: 325695 - View products that this article applies to.
This article was previously published under Q325695
Expand all | Collapse all

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 (TableName) 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:
  1. In Notepad, paste the following code in a new file:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    	<xs:element name="OrdersInventoryData" type="OrdersInventoryDataType" />
    	<xs:complexType name="ItemType">
    		<xs:sequence>
    			<xs:element name="id" type="xs:string" />
    			<xs:element name="qty" type="xs:integer" />
    		</xs:sequence>
    	</xs:complexType>
    	<xs:complexType name="OrderType">
    		<xs:sequence>
    			<xs:element name="OrderId" type="xs:string" />
    			<xs:element name="CustomerId" type="xs:string" />
    			<xs:element name="Item" type="ItemType" maxOccurs="unbounded" />
    		</xs:sequence>
    	</xs:complexType>
    	<xs:complexType name="InventoryType">
    		<xs:sequence>
    			<xs:element name="Item" type="ItemType" maxOccurs="unbounded" />
    		</xs:sequence>
    	</xs:complexType>
    	<xs:complexType name="OrdersInventoryDataType">
    		<xs:sequence>
    			<xs:element name="Order" type="OrderType" maxOccurs="unbounded" />
    			<xs:element name="Inventory" type="InventoryType" maxOccurs="unbounded"/>
    		</xs:sequence>
    	</xs:complexType>
    </xs:schema>
    					
  2. 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).
  3. 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.
  4. Add the OrderInventory.xml XML document that you just created to the project.
  5. 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.
  6. 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.
  7. Close the XML Designer window.
  8. In Solution Explorer, rename OrderInventory.xml to OrderInventory.xsd. To do this, right-click the file, and then click Rename.
  9. 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.

REFERENCES

You may also receive the "The same table (TableName) cannot be the child table in two nested relations" error message when you use XML files with Visual Studio .NET or with the Xsd.exe utility. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
325696 You receive an error message when you view multidimensional XML data in the Visual Studio .NET XML Designer

Properties

Article ID: 325695 - Last Review: June 14, 2006 - Revision: 3.4
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
Keywords: 
kbprb KB325695

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com