Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XML Schema Complex Types – Element-Only

XSD Element-Only


An element of a complex type that is "element-only" is an element that can contain only other elements.


Complex Type Containing Only Elements

The XML element, "person", contains only other elements:

  John

  Smith

You can define the "person" element in the schema like this:

  xs:complexType

    xs:sequence

     

     

   

 

Please note this xs:sequence. It means that the defined elements must appear in the "person" element in the order shown above.

Or you can give the complexType element a name and let the type attribute of the "person" element refer to this name (by using this method, several elements can refer to the same complex type):

  xs:sequence