XML Schema list element
Definition and usage
The list element defines a collection of single simpleType definitions.
This attribute defines a list of values as the values of a specified data type.
Element information
Occurrence times | One |
Parent element | simpleType |
Content | annotation, simpleType |
Syntax
<list id=ID itemType=QName any attributes > (annotation?,(simpleType?)) </list>
(? Symbol declarations can appear in the list element zero or one times.)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element. |
itemType | The name of the built-in data type or the 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, this 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 delimiters for list items.
Example 2
The following example demonstrates a simple type for a string column:
<?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>