Element listy schematów XML
❮ Pełne odniesienie do schematu XML
Definicja i użycie
Element listy definiuje element typu prostego jako listę wartości określonego typu danych.
Informacje o elemencie
- Elementy nadrzędne: simpleType
Składnia
<list
id=ID
itemType=QName
any attributes
>
(annotation?,(simpleType?))
</list>
(Znak ? deklaruje, że element może wystąpić zero lub jeden raz wewnątrz elementu listy)
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
itemType |
Specifies the name of a built-in data type or simpleType element defined in this or another schema. This attribute is not allowed if the content contains a simpleType element, otherwise it is required |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
Przykład 1
Poniższy przykład pokazuje prosty typ, który jest listą liczb całkowitych:
<?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 a document could look like this (notice that
the list will have five list items):
<intvalues>100 34 56 -23 1567</intvalues>
Uwaga: biały znak jest traktowany jako separator pozycji listy!
Przykład 2
Poniższy przykład pokazuje prosty typ, który jest listą ciągów:
<?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 a document could look like this (notice
that the list will have four list items):
<stringvalues>I love XML Schema</stringvalues>
❮ Pełne odniesienie do schematu XML