XML Schema any 元素

定义和用法

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

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

元素信息

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

语法

<any
id=ID
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
namespace=namespace
processContents=lax|skip|strict
any attributes
>
(annotation?)
</any>

(? 符号声明元素可在任何元素内出现零次或一次。) -> (? ສັນຍາການປະກາດສັນຍານສາມາດເພີ່ມຢູ່ພາກວັດຖຸໃດໆຢ່າງໜ້ອຍຫຼືຫນັງຫນຽງ.)

属性

id

Optional. Specify the unique ID of the element.

maxOccurs

Optional. Specify the maximum number of times the any element can appear in the parent element. The value can be an integer greater than or equal to zero. If you do not want to set any limit on the maximum number, use the string "unbounded". The default value is 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 this 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 can appear.
  • ##local - Elements not limited by a namespace can appear.
  • ##targetNamespace - Elements from the target namespace of the parent element containing this element can appear.
  • {URI references of namespaces, ##targetNamespace, ##local} list - Elements can appear from the namespace list separated by spaces. The list can contain the following: URI references of namespaces ##targetNamespace and ##local.

processContents

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

  • strict - XML processor ຕ້ອງຮັບຄວາມມະນຸດສະແນນທີ່ຕ້ອງການຈາກສະນາມນອກຈາກຄວາມມະນຸດສະແນນ ແລະ ຕ້ອງກວດກາທຸກສິ່ງໃນສະນາມນອກຈາກຄວາມມະນຸດສະແນນ. (ຄົນປະດິດ)
  • lax - ອັນຕະລາງຄືກັນ; ແຕ່ວ່າບໍ່ສາມາດຮັບຄວາມມະນຸດສະແນນ, ບໍ່ມີຄວາມຜິດພາດ.
  • skip - XML processor ບໍ່ຈະກວດກາວ່າທຸກສິ່ງໃນສະນາມນອກຈາກຄວາມມະນຸດສະແນນ.

any attributes

ຄວາມຄືນ. ກໍານົດປະເພດຂອງຜະລິດບໍ່ໄດ້ພົບຄວາມມະນຸດສະແນນບັນດາສິນຄໍາຊື່ນຫນັງ.

ຕົວຢ່າງ

ບົດສະຫຼຸບນີ້ສະແດງຄວາມວ່າ "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>