XSD Mode: XSD 1.0 or 1.1

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  User Guide and Reference > Editing Views > Schema View >

XSD Mode: XSD 1.0 or 1.1

In Schema View you can select whether the XML Schema (XSD) should be edited and validated according to the XML Schema 1.0 specification (XSD 1.0) or the XML Schema 1.1 specification (XSD 1.1). The XSD mode that is used for editing a file is based on two settings: one in the application, the other in the XSD document.

 

Selecting XSD mode

The XSD mode determines the Schema View editing and validation features (XSD 1.0 or 1.1) available for the active document. You can either: (i) make an application-wide setting, in which case all XSD documents in Schema View will be edited in the selected mode, or (ii) you can save the XSD version number in the XSD document and let the application automatically select the XSD mode according to this information.

 

Application-wide mode

The application-wide setting is made in the File section of the Options dialog (Tools | Options, see screenshot below). If you select the Version 1.0 or Version 1.1 radio button, then the selected mode becomes the application-wide mode. All XML Schema documents opened in Schema View will now be edited in this mode. (If you select the v1.1 if <xs:schema vc:minVersion="1.1", v1.0 otherwise setting, the mode will depend on information in the document and will not be application-wide. See Document-specific mode and the other sections below for information about this.)

XMLSchemaVersion

You can switch between the two application-wide modes (Version 1.0 and Version 1.1) at any time by selecting the option you want in the XML Schema Version setting of the Options dialog (screenshot above).

 

Note:If the current setting is an application-wide setting and you switch modes using the XSD 1.0 or XSD 1.1 button in the Schema Design toolbar (see next section), the mode switch will be temporary, and the mode will revert to the application-wide mode when the document is reloaded. A reload happens each time the view is changed or when Schema View is refreshed (via File | Reload).

 

Document-specific mode

You can also choose to save the XSD mode information in the XSD document itself. This would enable Schema View to automatically switch to the document's XSD mode when the document is loaded. You can add XSD mode information to an XSD document by clicking the XSD 1.0 or XSD 1.1 button in the Schema Design toolbar (screenshot below). On doing this, the selected mode is saved in the vc:minVersion attribute of the top-level xs:schema element. (The value of the vc:minVersion can also be added manually in Text View.)

ToolbarSchemaDesign

Note:The vc:minVersion attribute, if present, must be in the namespace http://www.w3.org/2007/XMLSchema-versioning. In this case, the XML Schema document must have a namespace declaration binding the vc: namespace prefix to this namespace. If you use the XSD 1.1 toolbar button (screenshot above), the namespace is added automatically. Clicking the XSD 1.0 toolbar button removes this namespace declaration if no other node name in the document is in this namespace.

 

To activate the document-specific mode and specify a document's XSD mode, do the following:

 

1.Activate document-specific mode: In the File section of the Options dialog (Tools | Options), set the XML Schema Version option to v1.1 if <xs:schema vc:minVersion="1.1", v1.0 otherwise (see screenshot below). This indicates to XMLSpy that the XSD mode in Schema View should be set according to the vc:minVersion attribute of the xs:schema element.

XMLSchemaVersionOn

2.Specify the document's XSD version: In the Schema Design toolbar (screenshot above), click the XSD 1.0 or XSD 1.1 button.  A confirmation dialog (screenshot below) pops up.

XSDVersionConfirm

3.Clicking Yes results in the following: (i) enters the corresponding value in the vc:minVersion attribute of the xs:schema element, and (ii) if XSD 1.1 was selected, declares the XMLSchema-versioning namespace with a binding to the vc: namespace prefix; if XSD 1.0 was selected, the namespace declaration is removed if no other node is in the XMLSchema-versioning namespace. The XML Schema document now contains the XSD version number. On saving the file, the XSD mode information is saved with it. When you reopen or reload the file, Schema View will automatically switch to the document's XSD mode as contained in the vc:minVersion attribute of the xs:schema element.

 

Note:If the document-specific mode option is selected, and if the XSD document has no vc:minVersion attribute or the value of the vc:minVersion attribute is other than 1.0 or 1.1, then Schema View defaults to XSD 1.0 mode.

 

Note:Do not confuse the vc:minVersion attribute with the xsd:version attribute. The former holds the XSD version number, while the latter hold the document version number.

 

XSD mode of new documents

When you create a new XSD document you will be prompted about whether you wish to create it as an XSD 1.0 or XSD 1.1 document. If XSD 1.1 is selected, the new document is created with the attribute /xs:schema/@vc:minVersion="1.1" and the XMLSchema-versioning namespace with a binding to the vc: namespace prefix is declared. If XSD 1.0 is selected, then neither the vc:minVersion attribute nor the XMLSchema-versioning namespace declaration is added. However, which XSD mode is actually enabled in Schema View depends also on the XML Schema Version selected in the File section of the Options dialog (Tools | Options). See the next section for details about how these two settings interact.

 

The enabled XSD mode

The XSD mode that is enabled in Schema View depends on both (i) the presence/absenceand, if present, the valueof the /xs:schema/@vc:minVersion attribute of the XSD document, and (ii) the XML Schema Version option selected in the File section of the Options dialog (Tools | Options, screenshot below).

XMLSchemaVersion

The following situations are possible. XML Schema Version in the table below refers to the selection in the XML Schema Version pane shown above. The vc:minVersion values in the table below refer to the value of the xs:schema/@vc:minVersion attribute in the XML Schema document.

 

XML Schema Version

vc:minVersion attribute

XSD mode

Always v1.0

Is absent, or is present with any value

1.0

Always v1.1

Is absent, or is present with any value

1.1

Value of @vc:minVersion

Attribute has value of 1.1

1.1

Value of @vc:minVersion

Attribute is absent, or attribute is present with a value other than 1.1

1.0

 

Note:In the situations described in the first two rows, it is possible that an XSD 1.1 schema is opened in XSD 1.0 mode and vice versa. The inconsistencies will be handled as described further below.

 

XSD mode features

The interface and editing features of Schema View will change according to which XSD mode (XSD 1.0 or XSD 1.1) is enabled.

 

If XSD 1.0 mode is enabled:

 

Editing support for new XML Schema 1.1 components and properties is not available. However, if XSD 1.1 components or properties are already present in the XSD document, these will be displayed and will be available for deletion.
Validation is performed against the XSD 1.0 specification. So, if an exclusively XSD 1.1 component or property (already) exists in the schema, a validation error is reported.

 

If XSD 1.1 mode is enabled, editing support is provided for all features of XML Schema 1.1. Validation is with respect to the XML Schema 1.1 specification.

 

Handling of XSD 1.1 features in XSD 1.0 mode

If an XSD 1.1 feature that is not supported in XSD 1.0 is present in the document (for example, an assertion), how such a feature is displayed and handled in XSD 1.0 mode is described below.

 

Assertions: If at least one assertion is present on the selected simple type, the Assertions tab is present in the Facets entry helper. No editing is possible except for deletion of the assertion.
Asserts: The assertion is displayed in the diagram of the complex type if present. No Assertions tab is available in the AAIDC pane. Assertion cannot be added via context menu. No editing of properties is possible except for deletion.
Attributes: New property inheritable is displayed if present. No editing is possible except for selecting the empty value (this is effectively a removal of properties).
Complex types: The new property defaultAttributesApply, if present, is displayed in the Details entry helper. No editing is possible except for selecting the empty value (this is effectively a removal of properties).
Documentation: New XSD 1.1-specific components and properties are not included in Schema View documentation.
Facets: Unknown facets cause validation errors and are displayed in red.
Find in schemas: New XSD 1.1-specific components and properties are ignored.
Identity constraints (IDCs): The property isRef is displayed in case of reference and can be switched off. It will be switched off as soon as the IDC’s name is modified.
Multiple substitution groups: Combo box to select single substitution group (only single substitution groups allowed in XSD 1.0).
Open content: Displayed in diagram if present. Cannot be added via context menu. No editing is possible except for deletion. Default Open Content is not displayed within complex types.
Override: Displayed in globals grid if present. Cannot be added via menu. No editing (of location) is possible except for deletion. Overriding components (that is, children of xs:override) are ignored and will not be included in the Components entry helper.
Schema settings: New properties defaultAttributes and xpathDefaultNamespace are displayed in dialog if present. No editing is possible except for selecting the empty value (this is effectively a removal of properties).
Simple types: Unknown types cause validation errors and are displayed in red.
Type Alternatives: Displayed in diagram if present. Cannot be added via context menu. No editing (of properties) is possible except for deletion.
Wildcards: New properties displayed if present. No editing is possible except for the selection of empty value (effectively a removal of properties).

 


© 2019 Altova GmbH