---
title: "What’s New in XML Schema 1.1?"
date: "2016-03-21"
categories: 
  - "development"
  - "tools"
  - "xml"
tags: 
  - "altova-online-training"
  - "xml-schema"
  - "xml-schema-1-1"
  - "xmlspy"
description: Explore the key enhancements in XML Schema 1.1, including assertions and conditional type alternatives, designed to improve flexibility and validation in XML development.
---
Status: #blog

Tags:  #altova-online-training #xml-schema #xml-schema-1-1 #xmlspy

Categories: [development](/blog/category/development.md) | [xml](/blog/category/xml.md)
# What’s New in XML Schema 1.1?

Since the introduction of XML Schema 1.0, the standard has been widely adopted. Developers have requested several changes over the years, most notably the ability to specify and validate more granular business rules and also to allow flexible schema evolution. There are numerous changes and enhancements in the [XML Schema 1.1 Recommendation](http://www.w3.org/TR/xmlschema11-1/) aimed at addressing these issues.

Let's take a look at the most notable new features and some resources for learning more or getting started right away with XML Schema 1.1.

![shutterstock_137938508](/blog/images/shutterstock_137938508.jpg)

<!--more-->

### Learn What's New in XML Schema 1.1

There’s a comprehensive explanation of the new and enhanced features in XML Schema 1.1 in our free, [online XML Schema training course](https://www.altova.com/aot/online-training.html), which you can access at any time and complete at your own pace. If you’re an experienced schema developer and simply want to learn about what’s new and enhanced in XSD 1.1, skip ahead to Chapter 9. This course is a great way to learn about XML Schema 1.1 and quickly adapt your schemas to take advantage of the new features.

 

![XML Schema 1.1 Training](/blog/images/xml-schema-1-1-training.png)

 

In this article, I’ll explain several of the highlights and show you how you can implement the new features using XMLSpy. Complete support for XML Schema 1.1 is provided in XMLSpy versions 2014 and higher, including validation of XSD and XML instance files based on XML Schema 1.1, as well as intelligent XSD 1.1 editing tools in the graphical [XML Schema 1.1 editor](https://www.altova.com/xmlspy/xml-schema-editor.html).

### Assertions

Assertions, also called co-constraints, in XML Schema 1.1 allow rules-based validation of business policies involving more than one element. These rules are defined using XPath expressions. For example, you can use the new <assert> element to test if an expense is less than or equal to the permitted amount, a date is with a certain time frame, and so on. In this example, the assertion specifies that the end time of a meeting must be greater than the start time. You can see this represented in XML Schema design view here:

![Assertions - Graphical View](https://lh6.ggpht.com/-0AwouJhf1UA/UtREYaoYlRI/AAAAAAAAAbQ/YtTI7Z7spJI/clip_image003_thumb.png?imgmax=800 "Assertions - Graphical View")

 

And in the corresponding code:

 

![XML Schema 1.1 Assertions](https://lh4.ggpht.com/-3cHGIZ4GF6U/UtREbHVLWOI/AAAAAAAAAbg/iFpwT04A808/clip_image004_thumb.png?imgmax=800 "XML Schema 1.1 Assertions")

 

It’s easy to review the assertions that exist in a schema using the Globals view, which provides an Assertions tab for XML Schema 1.1 documents. You can also add new assertions and select the XPath default namespace here.

 

![Adding assertions](https://lh5.ggpht.com/-p3B5JogWx24/UtREdQH_lkI/AAAAAAAAAbw/XZobzGyHc-M/clip_image005_thumb.png?imgmax=800 "Adding assertions")

 

Or, define them in the content model view by right clicking an element in the content model view and choosing Add child assertion. You can define the XPath test directly in the content model via the Details entry helper window.

 

![Assertion dialog](https://lh4.ggpht.com/-oKQlRSmEUjs/UtREfY8OlJI/AAAAAAAAAb8/4S0voU3k5B0/clip_image006_thumb.png?imgmax=800 "Assertion dialog")

 

This ability to define and validate business rules is a major advantage of XML Schema 1.1, and this graphical view helps guide you through the process.

### Conditional Type Alternatives

Conditional type alternatives are another feature designed to make XSDs more powerful by adding built-in flexibility. These allow a type to be dynamically assigned to an element based on an attribute value in the XML instance document. The xs:alternative element has two attributes: type and test. Here is an example using the Meeting schema we started with above.

 

![Conditional type alternative](https://lh3.ggpht.com/-iPc-_0cC1f4/UtREhR6JsxI/AAAAAAAAAcM/u0exmkn1Pk0/image_thumb.png?imgmax=800 "Conditional type alternative")

 

If the end-time of the meeting is before noon, the type of the meeting is MorningMeeting. After noon, it’s AfternoonMeeting. To define this in the [XML Schema designer](https://www.altova.com/xmlspy/xml-schema-editor.html), we simply right-click the Meeting element and choose Add Child / Alternative. Use the Details entry helper to enter an XPath expression, and then select the Type that will be dynamically assigned to the element from the Type drop down menu.

 

![XSD 1.1 conditional type alternative](https://lh4.ggpht.com/--KlKrmowu-M/UtREis-NKcI/AAAAAAAAAcc/vECoVx9djRY/clip_image007_thumb.png?imgmax=800 "XSD 1.1 conditional type alternative")

 

Now, any Meeting element in an XML instance with an end time after 12:00:00 will use the MeetingType AfternoonMeeting. Using a graphical [XSD editor](https://www.altova.com/xmlspy/xsd-editor.html) makes it easy to visualize and configure these relationships.

### Schema-wide Attributes

XML Schema 1.1 allows you to define a set of default attributes that automatically apply to every complex type in the schema. For instance, in our Meeting schema, it is helpful to have the attributes startTime and endTime apply to all elements, without having to add them manually, which is tedious and potentially error-prone – especially in a schema with a large number of elements. The xs:schema element in XML Schema 1.1 has an optional defaultAttributes element, which identifies an attribute group. (If there is a particular element in which it’s not desirable to apply the default attribute(s), you can specify that with defaultAttributesApply=”false”.) It’s easy to add an attributeGroup and define the default attributes in the XML Schema editor Globals view.

 

![Schema-wide attributes](https://lh5.ggpht.com/-kCqG7vqfWx8/UtREj-x9iMI/AAAAAAAAAcs/6cq-TJtaOG8/clip_image008_thumb.png?imgmax=800 "Schema-wide attributes")

 

Then, use the Schema Settings dialog accessed via the Schema design menu to select the attributeGroup you just created as the defaultAttributes from a drop-down list.

 

![Selecting an attribute group](https://lh3.ggpht.com/-DjkS3RvyNDk/UtRElO-eQoI/AAAAAAAAAc8/Z3L23X4_hz4/clip_image009_thumb.png?imgmax=800 "Selecting an attribute group")

 

Above are some of the major updates provided by XML Schema 1.1. Others include inheritable attributes, enhanced functionality for substitution groups, an xs:error datatype, and others. All of these are explained in detail with real-world example files in chapter 9 of the [XML Schema online training](https://www.altova.com/aot/online-training.html) course.

### Further Resources and Tools:

> [XML Schema 1.1 Recommendation](http://www.w3.org/XML/Schema) XMLSpy [XML Schema 1.1 Editor](https://www.altova.com/xmlspy/xml-schema-editor.html) and [validator](https://www.altova.com/xmlspy/xml-validator.html) RaptorXML [XML Schema 1.1 Validation Server](https://www.altova.com/raptorxml.html) Free Online [XML Schema 1.1 Training](https://www.altova.com/aot/online-training.html)
