Altova XMLSpy 2024 Enterprise Edition

Attributes, Attribute Groups, Attribute Wildcards

Home Prev Top Next

In the Attributes tab of the Attributes/Assertions/Identity Constraints (AAIDC) pane (screenshot below), you can:

 

Declare attributes locally on the selected complex type

Reference attribute groups for use on the selected complex type

Define attribute wildcards on the selected complex type

 

Note:If you have chosen the option to display attributes in the diagram (Schema Design | Configure View) rather than in the AAIDC pane, you can edit the properties of  attributes, attribute group references, and attribute wildcards in the diagram and Details entry helper.

 

icAttributesToggle

Display Attributes in Diagram: Enabled in Content Model View. Toggles the display of attributes between the diagram (toggled on) and the Attributes tab.

 

Attributes

In the Attributes tab of the Attributes/Assertions/Identity Constraints (AAIDC) pane (screenshot below), you can declare local attributes of elements and complex types, and the attributes that constitute attribute groups.

AttributesAAIDC01

To create attributes, do the following:

 

1.In Schema Overview, select the complex type or attribute group for which you wish to create the attribute.

2.In the Attributes tab, click the Append or Insert icon at top left and select Attribute.

3.In the row that is created for the attribute, enter the attribute's details (name, type, use, and default or fixed value). The name property is mandatory, and the default value of use is optional. The datatype and default/fixed value properties are optional.

 

Note:Attributes can be added to attribute groups only in Schema Overview, but to complex types in both Schema Overview and Content Model View.

 

Note:If an attribute has a type definition, then clicking its 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.

 

Default values and fixed values

A default value or fixed value, if specified in an attribute declaration, is applied in the instance document when that attribute is absent in the instance document. Either a default value or a fixed value can be specified, not both (see screenshot above). The default or fixed value must be valid according to the attribute's datatype. If use is set to required, then neither default nor fixed value is allowed.

 

Note the following:

 

Default values: A default value is inserted only if the attribute is missing. If the attribute is present and has a valid value, the default value is not inserted. If the value in the instance documents is invalid, an error is raised.

Fixed values: A fixed value is applied not only when the attribute is missing but also if the value in the instance document is not equal to the fixed value specified in the attribute's declaration.

 

Note:Default and fixed values can be specified on both local and global attributes. On local attributes they can be defined in both the Attributes tab of the AAIDC pane (screenshot above) and in the Details entry helper. On global attributes, they can be specified in the Details entry helper.

 

Attribute group references

If a global attribute group has been declared, you can add a reference to this attribute group in the definition of a complex type. Do this by selecting the complex type component in Schema Overview or Content Model View, then clicking the Append or Insert icon at top left of the Attributes tab of the AAIDC pane and selecting Attribute Group. In the attribute group row that is created, enter the name of the attribute group to be referenced (see screenshot below, which has two attribute group references). You can add multiple attribute groups.

AttributesAAIDCAttGrp

When the attribute group is selected in the Attributes tab, its properties can also be edited in the Details entry helper.

 

Attribute wildcards: anyAttribute

An attribute wildcard can be added to a complex type to allow the use of any attribute on an element. An attribute wildcard is defined with a single anyAttribute element. It would allow any number of attributes from the specified namespace to occur on the element in the instance document.

 

Add an attribute wildcard by selecting the complex type component in Schema Overview or Content Model View, then clicking the Append or Insert icon at top left of the Attributes tab of the AAIDC pane and selecting Any Attribute. A row for the attribute wildcard anyAttribute is created (see screenshot below).

AttributesAAIDCAny

In the Attributes tab, you can set the namespace property of anyAttribute. With the attribute wildcard selected in the Attributes tab, you can set additional properties in the Details entry helper (see screenshot above). Note that the notNamespace and notQName properties are XSD 1.1 features and so will not be available in XSD 1.0 mode.

 

Sorting attributes and attribute groups

You can sort the attributes and attribute groups in the Attributes tab by clicking the Sort icon in the tab's toolbar. In the Sort Components dialog that pops up (screenshot below), you can choose to sort either the selected single component and its siblings or the set of selected components. You can use Shift+click to select a range and Ctrl+click to add additional components to the selection.  

AttributesSortComponentsDlg

After setting the range you can choose to sort the entire range of attributes and attribute groups alphabetically (Name before kind), or attributes sorted alphabetically before attribute groups sorted alphabetically.

 

The sort order is immediately implemented in the text of the schema document; it is not just an interface mask.

 

Note:Attribute wildcards will not be included in the range to sort since they must always occur at the end of a complex type declaration and only one attribute wildcard is allowed in a single complex type declaration.

 

© 2017-2023 Altova GmbH