XML Schema any 元素

定义和用法

any 元素使来自指定命名空间的任何元素可以显示在包含 sequence 或 choice 元素中。

该元素使创作者可以通过未被 schema 规定的元素来扩展 XML 文档。

元素信息

项目 说明
出现次数 无限制
父元素 choice、sequence
内容 annotation

语法

any attributes
>
(annotation?)

(? 符号声明元素可在任何元素内出现零次或一次。)

属性

id

可选。规定该元素的唯一的 ID。

maxOccurs

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

minOccurs

Optional. Specify the minimum number of times the any element can appear in the parent element. The value can be an integer greater than or equal to zero. To specify that the any group is optional, set this attribute to zero. The default value is 1.

namespace

Optional. Specify the namespace of the elements that can be used. If no namespace is specified, the default value is ##any. If a namespace is specified, it must be one of the following values:

  • ##any - Elements from any namespace can appear (default).
  • ##other - Elements from any namespace outside the target namespace of the parent element of the element can appear.
  • ##local - Elements not qualified by a namespace can appear.
  • ##targetNamespace - Elements from the target namespace of the parent element containing the element can appear.
  • {URI references of namespaces, ##targetNamespace, ##local} list - Elements from the namespace list separated by spaces can appear. The list can contain the following: URI references of namespaces ##targetNamespace and ##local.

processContents

ທາງເລືອກ. ສັນຍາທີ່ຊີ້ໃຫ້ຄະນະກຳມະການຫຼື XML processor ທີ່ຈະກວດສອບ XML ສະບັບຕາມຢ່າງໃດທີ່ຈະຖືກກໍານົດໂດຍ any element. ຖ້າບໍ່ມີການກໍານົດ processContents, ຄົບເດັດແມ່ນ strict. ຖ້າມີການກໍານົດ processContents, ຕ້ອງເປັນຄຳວ່າດັ່ງຕໍ່:

  • strict - XML processor ຕ້ອງໄດ້ເຂົ້າເຖິງແບບສັນຍາທີ່ຕ້ອງການຂອງຊັນສມັນຊັ້ນ, ແລະຕ້ອງທຳການການກວດສອບທັງໝົດຢ່າງຫຼັງຈາກຊັນສມັນຊັ້ນ (ຄົບເດັດ).
  • lax - ຄືກັນກັບ strict; ແຕ່ວ່າເວລາບໍ່ສາມາດເຂົ້າເຖິງແບບສັນຍາ, ບໍ່ມີຄວາມຜິດພາດໃດໆ.
  • skip - XML processor ບໍ່ທຳການການກວດສອບທັງໝົດຢ່າງຫຼັງຈາກຊັນສມັນຊັ້ນທີ່ກໍານົດ.

any attributes

ທາງເລືອກ. ກໍານົດບັນດາຜະນຶກອື່ນໆທີ່ມີ non-schema ຊັນສມັນຊັ້ນ.

ບົດສະຫຼຸບ

ບົດສະຫຼຸບນີ້ສະແດງວ່າການຖະແຫຼງ "person" ຢ່າງໜຶ່ງ. ຜ່ານການນຳໃຊ້ <any> ຜູ້ຜະລິດສາມາດຂະຫຍາຍສານ "person" ທີ່ມີ (ພາຍຫຼັງ <lastname>):

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