XML Schema list element

Definition and usage

The list element defines a collection of simple types defined by a single simpleType.

This attribute defines a list of values as the values of the specified data type.

Element information

Occurrence Once
Parent element simpleType
Content annotation, simpleType

Syntax

<list
id=ID 
itemType=QName 
any attributes
>
(annotation?,(simpleType?))
</list>

(? The symbol declaration appears zero or one time in the list element.)

Attribute Description
id Optional. Specifies a unique ID for the element.
itemType The name of the built-in data type or simpleType element defined in the schema (or any other schema indicated by the specified namespace). A simpleType element that contains a list element is derived from the simple type specified by the list value. The list value must be a qualified name (QName). If the content contains a simpleType element, this attribute is not allowed; otherwise, the attribute is required.
any attributes Optional. Specifies any other attributes with a non-schema namespace.

Instance

Example 1

The following example demonstrates a simple type for a column of integers:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="intvalues" type="valuelist">
<xs:simpleType name="valuelist">
  <xs:list itemType="xs:integer"/>
</xs:simpleType>
</xs:schema>

The "intvalues" element in the document is similar to this (note that this list has five list items):

<intvalues>100 34 56 -23 1567</intvalues>

Note:Spaces are used as separators for list items.

Example 2

The following example demonstrates a simple type for a column of strings:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="stringvalues" type="valuelist">
<xs:simpleType name="valuelist">
  <xs:list itemType="xs:string"/>
</xs:simpleType>
</xs:schema>

The "stringvalues" element in the document is similar to this (note that this list has four list items):

<stringvalues>I love XML Schema</stringvalues>