About Top-Level Elements

In general, the W3C XML schema specification provides no functionality to assign which of the XML elements declared in the XML schema will be used as the root of an XML document that complies with that schema.

However, in many concrete situations, such an intention very much exists and needs to be documented somehow. To solve that problem, we have introduced a concept of top-level elements.

Top-level element is the one, which satisfies the following conditions:
  1. It is a global element (that is defined as a child of <xs:schema>)
  2. It is not abstract
  3. It has no parents in the same namespace. Precisely, the element is not included directly or by substitution in the content model of any other elements defined in any XML schemas targeting the element's namespace.
When an element matches all of those criteria, most likely it will be used as the root element of some or all XML documents described by the given XML schema.

Typically, very few such elements can be found in an XML schema (possibly one or two per a namespace). Using the template parameter:

Generate Details | XSD Components | Elements | Separate Top-Level Elements
you can separate the top-level elements and thereby to highlight what you intended to be the main element in your schema (e.g. <xs:schema> in XML schema for XML schemas).