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

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

Schema (XSD) 中的 XML Schema group 元素


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

Definition and Usage
定义和用法

The group element is used to define a group of elements to be used in complex type definitions.
group元素的作用是:定义一组在复合类型[complex type]中使用的元素。

Element Information
元素信息

  • Parent elements: schema, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)
    父类元素:schema、choice[选择]、sequence[序列]、complexType[符合类型]、restriction[限制] (包括simpleContent[单一内容]和complexContent[复合内容])、extension[扩展] (包括simpleContent[单一内容]和complexContent[复合内容])

Syntax
语法

<group
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>
(annotation?,(all|choice|sequence)?)
</group>

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

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
name Optional. Specifies a name for the group. This attribute is used only when the schema element is the parent of this group element. Name and ref attributes cannot both be present
可选参数。指定一个组名称。该属性仅当schema元素是group元素的父类元素时使用。该名称和ref 属性不能同时出现
ref Optional. Refers to the name of another group. Name and ref attributes cannot both be present
可选参数。引用其它的组名称。该名称和ref 属性不能同时出现
maxOccurs Optional. Specifies the maximum number of times the group element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1
可选参数。指定group元素在父类元素中出现的最大次数。其值可以大于等于0;或者,如果你不希望对最大值进行限制,可以使用“unbounded”。默认值是1
minOccurs Optional. Specifies the minimum number of times the group element can occur in the parent element. The value can be any number >= 0. Default value is 1
可选参数。指定group元素在父类元素中出现的最小次数。其值可以大于等于0。默认值是1
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定非schema命名空间的其它属性

Example 1
案例1

The following example defines a group containing a sequence of four elements and uses the group element in a complex type definition:
下面的案例定义了一组包含4个元素的序列,并在一个复合类型定义中使用了group元素:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:group name="custGroup"> <xs:sequence> <xs:element name="customer" type="xs:string"/> <xs:element name="orderdetails" type="xs:string"/> <xs:element name="billto" type="xs:string"/> <xs:element name="shipto" type="xs:string"/> </xs:sequence>
</xs:group>
<xs:element name="order" type="ordertype"/>
<xs:complexType name="ordertype"> <xs:group ref="custGroup"/> <xs:attribute name="status" type="xs:string"/>
</xs:complexType>
</xs:schema>

评论 (0) All

登陆 | 还没注册?