A global element is an element with a global scope. It is one that
has been declared as part of the main schema rather than as part of a content
model.
The following instructions were written for the Resource perspective,
but they will also work in many other perspectives.
To add a global
element:
- Open your XML schema in the XML schema editor.
- In the Outline view, select your schema. The entire
schema and its contents are displayed in the Design view.
- In the Design view, right-click in the Elements section
and click Add Element.
- In the Properties view, click the General tab,
and type a new name for the global element in the Name field.
- In the Properties view, you can select the attribute type from
the predefined list in the menu next to the Type field.
Alternatively, you can select Browse from
the list for more options.
The
Set Type dialog
box appears, and 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.
Select the type you want in the type list, then click OK.
- (Optional) Click the Other tab. In
this page, you can specify the following various values for the global element:
- abstract. Click true if you want the
global element to be abstract. When a global element is declared to be abstract,
it cannot be used in an instance document. Instead, a member of that global
element's substitution group must appear in the instance document.
- block. This field determines whether the global
element may be replaced by an element derived from it.
- final. This field determines whether this global
element may be derived from.
- fixed/default. Click Browse and
select Fixed or Default and
specify an appropriate value. If you select Fixed, the global element
has a fixed value, which cannot be changed. If you select Default,
the element has a default value.
- form. Use this field to indicate if the appearance
of this global element in an instance of the XML schema (an XML file associated
with the XML schema) must be qualified by a namespace.
- nillable. Select true if you do not
want the global element to be able to have any child elements, only attributes.
- substitutionGroup. A substitution group allows
elements to be substituted for other elements.
- Click the Attributes tab. You
can use this page to add attributes, attribute references, attributes group
references, and any attributes to your global element.
- An attribute associates an attribute name with a specific type
and value. To add an attribute, right-click in the Attributes page, and click Add
Attribute. You can specify the following values for
an attribute:
- fixed/default. Click Browse and
select Fixed or Default and
specify an appropriate value. If you select Fixed, the attribute has
a fixed value, which cannot be changed. If you select Default, the
attribute has a default value.
- form. Use this field to indicate if the appearance
of this attribute in an instance of the XML schema must be qualified by a
namespace.
- name. Enter the name of the attribute.
- type. Click Browse and
select the type of the attribute.
- use. This field indicates how an attribute
can be used in an instance document. If you select optional, the attribute
can appear once, but it does not have to. If you select required, the attribute
must appear once. If you select prohibited, the attribute must not appear. Note:
If you selected Default, you must select optional in
this field, otherwise the default value will not be valid.
- An attribute reference provides a reference to a global attribute.
To add an attribute reference, right-click in the Attributes page, and click Add
Attribute Ref. A declaration that references a global
attribute enables the referenced attribute to appear in the instance document
in the context of the referencing declaration. The menu option to add an attribute
reference only appears if there are global attributes defined elsewhere in
the document. Select the reference, then select the global attribute you want
it to reference from the ref list.
- An attribute group reference provides a reference to an attribute
group. To add an attribute group reference, right-click in the Attributes
page, and click Add Attribute Group Ref. A
declaration that references an attribute group enables the referenced attribute
group to appear in the instance document in the context of the referencing
declaration. The menu option to add an attribute group reference only appears
if there are attribute groups defined elsewhere in the document. Select the
reference, then select the attribute group you want it to reference from the ref list.
- An any element enables element content according
to namespaces, and the corresponding any attribute element
enables attributes to appear in elements. To add an any attribute,
right-click in the Attributes page and click Add Any Attribute.
You can specify the following values for an any attribute:
- For a namespace value, you can
select:
- ##any. This allows any well-formed XML from any namespace.
- ##local . This allows any well-formed XML that is not declared
to be in a namespace.
- ##other. This allows any well-formed XML that is not from the target
namespace of the type being defined.
- ##targetNamespace . This is shorthand for the target namespace
of the type being defined.
- For a processContents value, you can select:
- skip. The XML processor will not validate the attribute content
at all.
- lax. The XML processor will validate the attribute content as much
as it can.
- strict. The XML processor will validate all the attribute content.
- Click the Documentation tab if you want
to provide any information about this global 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 a global element, which is the representation
of any data that can be contained inside the global element. For more information
about working with content models, refer to the related tasks.