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

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XML Schema 所有元素


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

Definition and Usage
定义和用法

The all element specifies that the child elements can appear in any order and that each child element can occur zero or one time.
all 元素[所有元素]指明了子元素可以以任何顺序出现,并且每个子元素可以不出现或出现1次。

Element Information
元素信息

  • Parent elements: group, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
    父类元素:group[组]、complexType[复合类型]、restriction[限制](包括simpleContent[单一内容]和complexContent[复合内容])、extension[扩展] (包括simpleContent[单一内容]和complexContent[复合内容])。

Syntax
语法

<all
id=ID
maxOccurs=1
minOccurs=0|1
any attributes
>
(annotation?,element*)
</all>

(The ? sign declares that the element can occur zero or one time, and the * sign declares that the element can occur zero or more times inside the all element)
“?”符号用于声明元素可以出现的次数(0次或1次),“*”符号用于声明元素可以在all元素中出现的次数(0次或多次)。

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
maxOccurs Optional. Specifies the maximum number of times the element can occur. The value must be 1.
可选参数。指定元素可以出现的最大次数。值必须是1
minOccurs Optional. Specifies the minimum number of times the element can occur. The value can be 0 or 1. Default value is 1
可选参数。指定元素可以出现的最小次数。值可以是0或1。默认值是1
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定其它的属性(这些属性无schema命名空间)

Example 1
案例1

<xs:element name="person"> <xs:complexType> <xs:all> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType>
</xs:element>

The example above indicates that the "firstname" and the "lastname" elements can appear in any order but both elements MUST occur once and only once!
上述案例指定了“firstname”和“lastname”可以以任何顺序出现,但是二者仅能出现一次。

Example 2
案例2

<xs:element name="person"> <xs:complexType> <xs:all minOccurs="0"> <xs:element name="firstname" type="xs:string"/> <xs:element name="lastname" type="xs:string"/> </xs:all> </xs:complexType>
</xs:element>

The example above indicates that the "firstname" and the "lastname" elements can appear in any order and each element CAN appear zero or one time!
上述案例指定了“firstname”和“lastname”可以以任何顺序出现,二者可以出现零次或一次。

评论 (0) All

登陆 | 还没注册?