<xsd:all> 元素

允许组中的元素以任意顺序显示(或不显示)在包含元素中。

<all
  id = ID 
  maxOccurs= 1: 1 
  minOccurs= (0 | 1): 1 
  {any attributes with non-schema Namespace...}>
Content: (annotation?, element*)
</all>

属性

  • id
    该元素的 ID。 id 值必须属于类型 ID 并且在包含该元素的文档中是唯一的。

    可选项。

  • maxOccurs
    元素可出现的最大次数。 该值必须是 1。

    可选项。

  • minOccurs
    元素可出现的最小次数。 该值可以是整数 1。若要指定该元素是可选的,请将该属性设置为 0。 默认值为 1。

    可选项。

元素信息

出现次数

一次

父元素

grouprestriction (simpleContent)extension (simpleContent)restriction (complexContent)extension (complexContent)complexType

内容

annotationelement

示例

下面的示例定义一个复杂数据类型,包含 all 元素以及下面示例的 XML 实例文档的三个元素:

<?xml version="1.0"?>
<myElement myAttribute="1.1"> 
    <thing2>Some</thing2>
    <thing3>text</thing3>
    <thing1>for you</thing1>
</myElement>
<xs:element name="thing1" type="xs:string"/>
<xs:element name="thing2" type="xs:string"/>
<xs:element name="thing3" type="xs:string"/>

<xs:attribute name="myAttribute" type="xs:decimal"/>

<xs:complexType name="myComplexType">
 <xs:all>
  <xs:element ref="thing1"/>
  <xs:element ref="thing2"/>
  <xs:element ref="thing3"/>
 </xs:all>
 <xs:attribute ref="myAttribute"/>
</xs:complexType>

其他资源

有关更多信息,请参见“W3C XML Schema Part 1: Structures Recommendation”(W3C XML 架构第 1 部分:结构建议),网址为 www.w3.org/TR/2001/REC-xmlschema-1-20010502/\#element-all。

另请参见

参考

XML 架构 (XSD) 参考
XML 架构元素