XML Schema sequence element

Definition and usage

The sequence element requires that the elements within the group appear in the specified order within the containing element. Each child element can occur 0 times to any number of times.

element information

occurrence times once within a group; otherwise unrestricted.
parent element group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)
内容 annotation、any、choice、element、group、sequence

语法

ਕੋਈ ਵਿਸ਼ੇ
>
(annotation?,(element|group|choice|sequence|any)*)

(? 声明在 sequence 元素中该元素可出现零次或一次。)

属性 描述
id 可选。规定该元素的唯一的 ID。
maxOccurs 可选。规定 any 元素在父元素中可出现的最大次数。该值可以是大于或等于零的整数。若不想对最大次数设置任何限制,请使用字符串 "unbounded"。 默认值为 1。
minOccurs 可选。规定 any 元素在父元素中可出现的最小次数。该值可以是大于或等于零的整数。若要指定该 any 组是可选的,请将此属性设置为零。 默认值为 1。
ਕੋਈ ਵਿਸ਼ੇ ਵਿਕਲਪਿਤ। ਕਿਸੇ non-schema ਨਾਮ ਸਪੇਸ ਨਾਲ ਸਬੰਧਤ ਕਿਸੇ ਹੋਰ ਵਿਸ਼ੇਸ਼ ਵਿਸ਼ੇ ਨੂੰ ਨਿਰਧਾਰਿਤ ਕਰੋ。

ਇਨਸਟੈਂਸ

ਉਦਾਹਰਣ 1

ਇਹ ਇੱਕ "personinfo" ਏਲੀਮੈਂਟ ਲਈ ਘੋਸ਼ਣਾ ਹੈ ਜਿਸ ਨੂੰ ਲਾਜ਼ਮੀ ਤੌਰ 'ਤੇ ਹੇਠ ਲਿਖੇ 5 ਏਲੀਮੈਂਟਾਂ ਨੂੰ ਕਿਸਮ ਨਾਲ ਕਵਰ ਕੀਤਾ ਜਾਣਾ ਚਾਹੀਦਾ ਹੈ: "firstname", "lastname", "address", "city", ਅਤੇ "country"。

<xs:element name="personinfo">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="firstname" type="xs:string"/>
      <xs:element name="lastname" type="xs:string"/>
      <xs:element name="address" type="xs:string"/>
      <xs:element name="city" type="xs:string"/>
      <xs:element name="country" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

ਉਦਾਹਰਣ 2

ਇਹ ਉਦਾਹਰਣ "pets" ਇਕਾਈ ਦੀ ਘੋਸ਼ਣਾ ਹੈ ਜੋ ਕਿ ਕੋਈ ਵੀ ਗਾਂਡੇ ਜਾਂ ਬਿਲਕੁਲ ਨਹੀਂ ਹੋ ਸਕਦੀ ਹੈ:

<xs:element name="pets">
  <xs:complexType>
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="dog" type="xs:string"/>
      <xs:element name="cat" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>