Elements are fundamental building blocks in XML. Element declarations
provide value constraints, provide a description that can be used for validation,
establish constraining relationships between related elements and attributes,
and control the substitution of elements.
The following instructions were written for the Resource perspective,
but they will also work in many other perspectives.
To add an element:
- To add an element, in the Design view, right-click the content
model you want to work with and click Add Element.
The element appears attached to the content model in the Design view.
- In the Design view, select the element, and click the current
(default) name of the element, which puts you in direct editing mode, then
type the new Name and press enter.
- In the Design view, click the current (default) element type
and select a type from the menu. Alternately, you can select browse to invoke
the Set Type dialog for more options. The Set Type dialog lists
all built-in and user-defined types currently available. You can change the Scope of
the list by selecting one of the following options:
- Workspace. Lists all of the types available in
your workspace.
- Enclosing Project. Lists all of the types available
in the project that contains your file.
- (Default) Current Resource. List all of the types
available in your current file.
- Working Sets. List all the types available within
the selected working set.
- (Optional) In the Properties view, select the appropriate value
in the MinOccurs field. This is the number
of times the element can appear in an instance document. If you want the element
to be optional, select 0. Otherwise, select 1.
- (Optional) Select the appropriate value in the MaxOccurs field.
This is the maximum number of times the element can appear in an instance
document. Select unbounded to indicate there is no
maximum number of occurrences.
- Click the Documentation tab if you want
to provide any information about this element. The Documentation page
is used for human readable material, such as a description.
- Click the Extensions tab if you want to
add application information elements to your annotations of schema components.
The Extensions page allows you to specify the
schema and add XML content to your annotations.
You can add a content model to an element, which is the representation
of any data that can be contained inside the element. For more information
about working with content models, refer to the related tasks.