XML Tutorial/XML Schema/list — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 11:26, 26 мая 2010
Содержание
- 1 A list data type is derived from an atomic data type that allows white space
- 2 length of our list is five
- 3 Restrict a list type with the xsd:length, xsd:maxLength, xsd:minLength, and xsd:enumeration facets.
- 4 The list method uses a finite sequence of itemType attributes to derive a new type
- 5 Using a <list> declaration, you can base your list items on a specific <simpleType>
A list data type is derived from an atomic data type that allows white space
<source lang="xml">
<simpleType name="myLuckyNumbers">
<list itemType="decimal"/>
</simpleType>
<numbers xsi:type="myLuckyNumbers"> 3 7 13 17 21.5 </numbers></source>
length of our list is five
<source lang="xml">
<simpleType name="myString">
<list itemType="string"/>
</simpleType>
<string_list xsi:type="myString">
This string is a list
</string_list></source>
Restrict a list type with the xsd:length, xsd:maxLength, xsd:minLength, and xsd:enumeration facets.
<source lang="xml">
<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.wbex.ru" xmlns="http://www.wbex.ru" elementFormDefault="qualified"> <xsd:simpleType name="three_datelist"> <xsd:list base="xsd:date"> <xsd:length value="3" /> </xsd:list> </xsd:simpleType> <xsd:element name="list_of_3_birthdays" type="three_datelist" />
</xsd:schema>
File: Data.xml <?xml version="1.0"?> <list_of_3_birthdays>1893-04-20 1904-05-11 1852-06-25</list_of_3_birthdays></source>
The list method uses a finite sequence of itemType attributes to derive a new type
<source lang="xml">
<simpleType name="websafe_hex">
<list itemType="string"/>
</simpleType>
<color xsi:type="websafe_hex"> 00 33 66 99 cc ff</color></source>
Using a <list> declaration, you can base your list items on a specific <simpleType>
<source lang="xml">
<list itemType="name of simpleType used for validating items in the list"> You specify the type of items by including the itemType attribute. itemType attribute should be a reference to a global <simpleType> definition or built-in XML Schema datatype. The <list> declaration allows you to specify your itemType by creating a local <simpleType> definition.
<simpleType name="ContactTagsType">
<restriction base="string"> <enumeration value="author" /> <enumeration value="xml" /> <enumeration value="poetry" /> <enumeration value="consultant" /> <enumeration value="CGI" /> <enumeration value="semantics" /> <enumeration value="employees" /> </restriction>
</simpleType>
<list> declaration: <simpleType name="ContactTagsListType">
<list itemType="contacts:ContactTagsType"/>
</simpleType></source>