XSD Empty Elements

A complex element with no contents, but only attributes is called an empty complex element.

Complex Empty Elements:

Example 1:


In the above example, the “student” element has no content at all.

Example 2:



In the above example, a complex type is defined with complex content. A type that allows elements in its content must be defined to define a type with no content. However, no elements are declared. To signal that the intention is to restrict or extend the content model of a complex type, and the restriction of integer declares one attribute but does not introduce any element content, the complex content element is used.

Example 3:



In the above example, we are declaring the “student” element more compactly.

Example 4:



The complex Type element can also be provided with a name. It means that the “student” element can have a type attribute to refer to the name of the complexType. Several elements can refer to the same complex type by using this method.