XML Schema listElement


XML Schema 参考手册Complete XML Schema Reference Manual

Definition and Usage

The list element defines a collection of a single simpleType definition.

Element Information

  • Parent element: simpleType

Syntax

<list
id=ID
itemType=QName
any attributes
>

(annotation?,(simpleType?))

</list>

(The ? sign declares that the element can occur zero or one times inside the list element.)

Attributes Description
id Optional. Specifies a unique ID for the element.
itemType The name of a built-in data type or simpleType element defined in this schema (or another schema indicated by the specified namespace). The simpleType element containing the 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.

Example 1

The following example shows a simple type for a list 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 would look like this (note that the list has five list items):

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

Note:Whitespace is used as the delimiter between list items.

Example 2

The following example shows a simple type for a list 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 would look like this (note that the list has four list items):

<stringvalues>I love XML Schema</stringvalues>


XML Schema 参考手册Complete XML Schema Reference Manual Other Extensions