This documentation is archived and is not being maintained.

Creating Unnamed Complex Types

Visual Studio .NET 2003

An unnamed complex type is a user defined type definition that is constructed in-line as part of the content model definition (as opposed to a global declaration being named and explicitly referenced). Unnamed types are typically used when a particular content model is needed to describe a single occurrence of an element. If you need to reuse a type definition then you should create a named type. For more information, see Named vs. Unnamed Types and Groups.

Unnamed complex types can be created with the XML Designer by adding elements and attributes to the design grid of an existing element.

To gain an understanding of where unnamed complex types fit into the overall process of creating an XML Schema, see Creating XML Schemas: High-Level Process for a summary of the steps and Walkthrough: Creating an XML Schema with the XML Designer for step-by-step instructions for a representative scenario: creating a purchase-order schema.

To create a new unnamed complexType

  1. Add an XML Schema or Dataset item to your project. For more information, see Adding New Schemas.
  2. Drag an element from the XML Schema tab of the Toolbox onto the design surface.
    Note   An unnamed type is defined inline as part of an element declaration. On the design surface, you create an unnamed complex type by building up the content model in the design grid of an element.
  3. In the grid header, select element1 and type in a new name for the element.
  4. Choose unnamed complex type from the list in the grid header.
  5. To define the content of an unnamed complex types, follow these steps:
    1. In the first empty row in the grid, select the small cell next to the asterisk to access the element type drop-down.
    2. Choose the type of element from the list.
    3. Use the TAB key to navigate to the next cell and replace the default name with a new name for this element.
    4. In the third cell, select the type for the element. You can choose an existing type, an unnamed type, or an existing user-defined type.
      Note   If you choose an unnamed type, a child element will appear on the design surface. Follow the procedure in step 5 to define that type as well.
  6. Repeat Step 5 until the type is fully defined.

See Also

Walkthrough: Creating an XML Schema with the XML Designer | complexType Element | XML Schemas and the XML Designer | XML Elements, Attributes, and Types | Named vs. Unnamed Types and Groups | User-Defined Simple Types in XML Schemas | Complex Types in XML Schemas | Relational Data in XML Schemas | XML Files