自强学堂
自强学堂:学习、分享、让你更强!
Schema 实例HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

XML Schema group 元素

XML Schema 参考手册 完整 XML Schema 参考手册

定义和用法

group 元素用于定义在复杂类型定义中使用的元素组。

元素信息

  • 父元素: schema, choice, sequence, complexType, restriction (both simpleContent and complexContent), extension (both simpleContent and complexContent)

语法

<group
id=ID
name=NCName
ref=QName
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
any attributes
>

(annotation?,(all|choice|sequence)?)

</group>

(? 符号声明在 group 元素中,该元素可出现零次或一次。)

属性描述
id可选。规定该元素的唯一的 ID。
name

可选。规定组的名称。该名称必须是在 XML 命名空间规范中定义的无冒号名称 (NCName)。

仅当 schema 元素是该 group 元素的父元素时才使用该属性。在此情况下,group 是由 complexType、choice 和 sequence 元素使用的模型组。

name 属性和 ref 属性不能同时出现。

ref

可选。引用另一个组的名称。ref 值必须是 QName。 ref 可以包含命名空间前缀。

name 属性和 ref 属性不能同时出现。

maxOccurs

可选。规定 group 元素可在父元素中出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。默认值为 1。

minOccurs

可选。规定 group 元素可在父元素中出现的最小次数。该值可以是大于或等于零的整数。默认值为 1。

any attributes

可选。规定带有 non-schema 命名空间的任何其他属性。

实例 1

下面的例子定义一个包含四个元素的序列的组,并在一个复杂类型定义中使用了这个 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>


XML Schema 参考手册 完整 XML Schema 参考手册