How to: Create Tables in XML Schemas (XML Designer)
TOC
Collapse the table of content
Expand the table of content
This documentation is archived and is not being maintained.

How to: Create Tables in XML Schemas (XML Designer) 

NoteNote

In versions prior to Visual Studio 2005, the XML Designer is the designer for typed datasets and XML schema. The XML Designer can still be used to create and edit XML schema files. However, in the current version, the designer for creating and editing typed datasets is the Dataset Designer. For more information, see Dataset Designer.

This page assumes you are working with the XML Designer. To open a typed dataset file with the XML Designer, right-click the file in Solution Explorer, point to Open With, and then click XML Schema Editor.

You can create tables and columns in XML Schemas in order to validate that table representations in XML data contain valid structure as well as valid data types.

Visual representation of a table in the XML Designer
XML Schema Customers Table

In XML Schemas, tables can be constructed manually or automatically with the XML Designer depending on the availability of a data source that represents the tables you need to validate within your application. You can also construct your schema both ways. For example: suppose you need to create a schema to validate XML data that includes a table with customer information and a table with customer feedback from your customer service department. Your organization already has the customer information table in an existing database; this can be created in your new schema automatically from your existing data source. The new table with customer feedback can be created manually and a relationship can be defined between the two tables.

Automatic Table Construction

You can use individual tables that are in existing data sources to easily construct schemas.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To automatically create table representations in XML Schemas using existing data sources.

  1. In Solution Explorer, right click the project you want to add the XML Schema to, select Add, and then select Add New Item.

  2. In the Add New Item dialog box, select XML Schema, give the schema a name, and then click Open.

    Visual Studio adds a new, blank schema file (.xsd) to the project.

  3. In Server Explorer, expand the Data Connections node and then expand the node for the connection to the data source you want to use.

    NoteNote

    If you don't already have a connection, create one. For more information, see Adding New Data Connections in Server Explorer.

  4. In the Connection node, expand the node for the Tables you want to infer the schema structure from.

  5. Drag the selected table onto the XML Designer.

  6. Save the schema.

  7. Repeat steps 4 and 5 to add more tables to your schema.

Manual Table Construction

If your schema requires table representations that have no available data sources to base them on, you can construct them manually with the XML Designer.

To manually create table representations in XML Schemas

  1. In Solution Explorer, right-click the project you want to add the schema to, select Add, and then select Add New Item.

  2. In the Add New Item dialog box, select XML Schema, give the schema a name, and then click Open.

    Visual Studio adds a new, blank schema file (.xsd) to the project.

  3. Drag an Element from the XML Schema tab of the Toolbox onto the designer.

    A table definition is added to the schema,

  4. Name the table by overwriting Element1 in grid header of the element.

  5. Move to a blank line in the table definition and select either Element or Attribute from the type drop-down.

    A column definition is added to the schema.

  6. Assign a name and a data type to the new column definition.

  7. Repeat Steps 3 through 5 for each table you want to add to the schema.

  8. Save the schema.

Next Steps

If you need to make changes to the schema, you can use the XML Designer to add, edit, and remove elements.

See Also

Show:
© 2016 Microsoft