当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML Schema list 元素

Schema (XSD)
Schema (XSD) 介绍
为何使用 XML Schemas?
如何定制 XSD
XSD - <schema>元素
XSD 简单元素
XSD 属性
XSD 约束面
XSD 复合元素
XSD 复合空元素
XSD 复合纯元素
XSD 复合纯文本
XSD 混合内容的复合类型
XSD 指示器复合类型
XSD <any> 元素
XSD <anyAttribute> 元素
XSD 元素替代
XSD 实例
XSD 字符串数据类型
XSD 日期数据类型
XSD 小数数据类型

Schema (XSD) 中的 XML Schema list 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 359 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The list element defines a simple type element as a list of values of a specified data type.
list 元素定义了一个作为指定数据类型的值的列表的简单类型元素。

Element Information
元素信息

  • Parent elements: simpleType
    父类元素:simpleType[简单类型]

Syntax
语法

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

(The ? sign declares that the element can occur zero or one time inside the list element)
“?”符号用于声明元素在list元素中允许出现的次数(0次或1次)

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
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
指定在当前的schema元素中或另一个schema元素中定义的内置数据类型或simpleType[简单类型]元素的名称。如果内容中不包含simpleType[简单类型]元素,那么不允许使用该属性

any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定其它的属性(这些属性无schema命名空间)

Example 1
案例1

The following example shows a simple type that is 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>

可以将文档中的 "intvalues" 元素看成下面的形式(注意:该列表将包含5个列表项):

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

Note: White space is treated as the list item separator!
注意:空格符将作为列表项的分隔符!

Example 2
案例2

The following example shows a simple type that is 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>

可以将文档中的 "stringvalues" 元素看成下面的形式(注意:该列表将包含4个列表项):

<stringvalues>I love XML Schema</stringvalues>

评论 (0) All

登陆 | 还没注册?