Global Components
Global components are those that are added as children of the top-level xs:schema element (as opposed to local components, which are created within other components). Some global components, such as complex types, elements and attributes can be referenced by other components in the schema.
Creating global components in Schema Overview
Global components are typically created and edited in Schema Overview. In Schema Overview, they are added via the Append or Insert icons. The content model of a global component (if the global component can have one, see table below) is created and edited in the Content Model View of that global component. (Click the Switch to Content Model View icon to the left of a component's name to go to Content Model View.)
Some global components, on being created in Schema Overview, are also added to the Components entry helper. If a component has a content model, double-clicking its name in the Components entry helper will open the content model for editing in Content Model View.
If the global component has a type definition (simple type or complex type), then clicking the component's context menu command Go to Type Definition will take you to the type definition. In the case of built-in simple types, a message box appears that contains information about the simple type.
Note: | You can also create some global components (elements, attributes, simple types, complex types, and model groups) while editing in Content Model View. Right-click anywhere in the window and select New Global | < Type of Global Component >. |
Note: | While editing in Content Model View, you can make a local element a global element—or a global complex type if the element has an element or attribute child. Select the local element, right-click anywhere in the window, and select Make Global | Element or Make Global | Complex type. |
Global component | Location in Schema | Content Model |
include | Beginning | No |
import | Beginning | No |
redefine | Beginning | No |
override 1.1 | Beginning | No |
defaultOpenContent 1.1 | After Includes, Imports, Redefines Overrides; before any other | Yes |
element | Anywhere after defOpenCont | Yes |
group | Anywhere after defOpenCont | Yes |
simpleType | Anywhere after defOpenCont | No |
complexType | Anywhere after defOpenCont | Yes |
attribute | Anywhere after defOpenCont | No |
attributeGroup | Anywhere after defOpenCont | No |
notation | Anywhere after defOpenCont | No |
annotation | Anywhere after defOpenCont | No |
Comment | Anywhere | No |
Processing instruction | Anywhere | No |
Given below are key points about editing these components in Schema View.
Includes, Imports, Redefines, and Overrides
These four global components allow other schema documents to be reused within the current schema document.
•Includes reuse documents that have the same target namespace as that of the current document.
•Imports reuse documents that have other target namespaces as that of the current document.
•Redefines and Overrides are types of Includes in that they have the same target namespace as the current document. They, however, modify parts of the included schemas. Redefines are a 1.0 feature and are deprecated in 1.1. Overrides, which are a 1.1 feature, are more flexible and have been designed to replace Redefines in 1.1.
All four have a schemaLocation attribute that points to the schema to be reused. In Schema View, when you double-click in the loc field of these components, you can browse for the file to reuse and set its path relative to the current document. The import component additionally has a namespace attribute that holds the target namespace of the imported schema.
When a schema is reused in the current schema document (via includes, imports, redefines, or overrides), its global components, namespaces, and identity constraints are displayed in the Components entry helper of the current document.
Redefines
In a redefine component, you can modify complex types, simple types, model groups and attribute groups. The component to be redefined will be in the schema specified in the loc field of the redefine component (in the screenshot below the components to be redefined are in the schema ExpReport.xsd). After a redefine component is added, you must add the component to be redefined into a position between the redefine and end of redefine rows of the global components list (see screenshot below, where the components New and emailType are redefined). These two components exist in the schema ExpReport.xsd and are being redefined for the current schema.
To redefine a component, do the following:
1.Select the end of redefine row.
2.Click the Insert icon in the top left of Schema Overview.
3.Select the kind of component you wish to define (complex type, simple type, model group or attribute group). The component is added within the redefine component.
4.Give it the same name as the component you wish to redefine. The component will now have all the properties of the component from the schema that is being reused.
5.Redefine the component by selecting it and modifying its properties in the Details and Facets entry helpers, or by modifying its content model in Content Model View (if it has a content model).
Note: | You might also be able to insert the components to be redefined as follows: either from elsewhere in the global components list or from the Components entry helper, using drag-and-drop or copy-paste. |
Redefined components can be referenced by other components in the schema.
Overrides
In an override element you can define the following components: complex types, simple types, global elements, global attributes, model groups, attribute groups, and notations. If, within an override element, one of these components is defined, then this component will replace, in the overridden schema, all components of the same kind that have the same name as the overriding component. The overridden schema is specified in the loc field of the Override.
Overrides differ from Redefines (see above) in that they are components defined from scratch and not based on any reused component. In Schema View, you add components for overriding similarly to how you add components for redefining. Insert the overriding component above the end of override row and then define its properties. See the 'Redefine' section above. The main difference between an Override and a Redefine is that when a component is added to an Override, it is not based on any component from the reused schema.
Default open content
The defaultOpenContent element is new in XSD 1.1 and specifies that one or more undefined elements can be added to any complex type of mixed or element-only content. It is similar to the openContent element (also new to XSD 1.1), the main difference being that while the openContent element applies to a single complex type, the defaultOpenContent element applies to all complex types in the schema.
The defaultOpenContent element occurs once in the document (see screenshot below), after Includes, Imports, Redefines, and Overrides, and before the definitions of components. It has a mode attribute which can take a value of either interleave or suffix. The default is interleave.
The defaultOpenContent element has a content model that you can edit in Content Model View. Once declared, the defaultOpenContent element will apply to all complex types in the schema. In the screenshot below, you can see that the defaultOpenContent has been applied automatically to the OfficeType and Desc complex types.
To override the defaultOpenContent element when it is applied to a particular complex type, add a child openContent element to that complex type. In the screenshot below, the Desc element with the defaultOpenContent element (see screenshot above) has had an openContent element added to it that overrides the defaultOpenContent element.
Global elements (element)
In Schema Overview, you can create a global element. If the global element is to have a content model, then this is defined in the Content Model View of the global element. With the element selected in either view, you can define attributes, assertions, and identity constraints in the respective tabs of the AAIDC pane. Facets and other properties can be defined in the element's Facets and Details entry helpers. Global elements can then be referenced by complex types.
Model groups (group)
In Schema Overview, you can create named model groups that can then be referenced in complex types. A named model group (the xs:group element) allows you to predefine a content model that can be reused. It can contain one of three kinds of child model group: a sequence group, a choice group, or an all group.
You create a named model group in Schema Overview by adding a Group component, giving it a name, and then defining its content model in Content Model View. The named model group can then be added to the content model of a complex type.
Named simple types (simpleType)
In Schema Overview you can create named simple types (see screenshot below), which can then be referenced in element and attribute declarations.
In the Details entry helper you specify the content of the simple type (restriction, list, union) and the corresponding type: respectively, the base type, item type, and member type. In the screenshot below, for example, the base type of the simple type's restriction is xs:integer. See the Details entry helper section for more information. To restrict a simple type with facets, use the options in the Facets entry helper.
Note: | Anonymous types can be declared on an element or attribute of simple content in either Schema Overview or Content Model View. When you set the derivedBy property (in the Details entry helper) to restriction, list or union, you create an anonymous simple type within that element or attribute declaration. You can define restriction facets (in the Facets entry helper) and other properties in the Details entry helper. |
Named complex types (complexType)
In Schema Overview you can create named complex types, which can then be referenced in element declarations. With the named complex type selected in either view, you can define its attributes and assertions in the respective tabs of the AAIDC pane.
A complex type can have four types of content (see list below). You specify the various types of content in the Details entry helper as described below and, if desired (and allowed), a content model in Content Model View.
•Simple content: Set the base type of the simple content (see screenshot below). The mixed attribute (for mixed content) must have a value of false (the default value); this is why true in the screenshot below is displayed in red. No content model is allowed.
•Element-only content: Create child elements in the content model diagram. There will be no base type.
•Mixed content: The mixed attribute must be set to true. Character data can be present anywhere in the element among child element nodes. The character data does not have any datatype, so there must be no base type (see screenshot above). Child elements can be created in the content model diagram.
•Empty content: The element will have neither character data nor child elements. There must be no base type and mixed must be false. Data in empty-content elements is typically stored in attributes.
Note: Attributes and assertions can be set ( in the AAIDC pane) on all four types of content.
Note: | Anonymous complex types are created within an element by creating a content model for that element in Content Model View. |
Global attributes and attribute groups (attribute, attributeGroup)
Global attributes and attribute groups are added in Schema Overview.
•Properties of a global attribute are defined in the attribute's Details entry helper.
•After creating a global attribute group, you can add attributes to the group as follows: (i) Select the global attribute group in the global components list; (ii) Add attributes in the Attributes tab of the AAIDC pane; and (iii) Define the properties of each attribute in the Details entry helper of the selected attribute.
After global attributes and attribute groups have been created, they can be referenced in the declarations of elements and complex types.
Notations (notation)
Notations are always global; there are no local notations. The properties of a notation are specified in the Details entry helper of the notation. The notation's name can be specified directly in the global components list. All notations in the schema are displayed in the Components entry helper for ease of reference.
Global annotations
Global annotations are global components and are not the same as the optional annotations that are available for some global components. You can edit a global annotation in the Annotation dialog (screenshot below), which is accessed by right-clicking the Annotation global component and selecting Whole Annotation Data.
Each annotation can have an id attribute and multiple child documentation and/or appinfo elements. You can add documentation or appinfo elements by clicking the Append or Insert buttons at the top left of the dialog and then selecting the doc or app item from the respective combo boxes. Select a doc or app item in the top pane of the dialog and enter its content in the Content pane. If you wish to create a new line in the content (and so make the content multi-line content), press Enter. In the screenshot above, the documentation element is selected and can be seen to have two-line content. For each documentation or appinfo element, you can also enter optional source and xml:lang attributes.
In Schema Overview, only the first documentation or appinfo element of the global annotation is displayed and can be edited directly in the global components list. If that content is multi-line, placing the cursor over it reveals all the lines in a multi-line popup box. To display or edit the contents of the other documentation and/or appinfo elements, go to the Annotation dialog of that global annotation.
Note: | The optional annotations that are available for some global components can also be edited via the Annotation dialog in exactly the same way as for global annotations as described above. |
Comments and processing instructions
Comments and processing instructions can be inserted anywhere in the global components list in Schema Overview. They cannot be added in Content Model View. If one or more comments or processing instructions are present within simple types or complex types, they are collected and moved to the end of the enclosing object. It is therefore recommended that you use annotations instead of comments in such cases.