xml – 如何指定允许任何顺序的一系列元素的XSD?

我有一些看起来像这样的XSD:

<element name="a">
  <complexType>
    <sequence>
      <element name="b" type="t:typ" minOccurs="1" maxOccurs="unbounded" />
      <element name="c" type="t:typ" minOccurs="1" maxOccurs="unbounded" />
    </sequence>
  </complexType>
</element>

我如何改变它,以便代替序列,我可以允许标签b和c以任何顺序混杂,例如我怎么才能使这个有效?

<a>
  <b />
  <c />
  <b />
  <c />
  <b />
  <b />
</a>

‘all’选项听起来很有希望,但它似乎只允许每个子元素中只有一个.

解决方法

我相信你想要这个:

<element name="a">
  <complexType>
    <choice maxOccurs="unbounded">
      <element name="b" type="t:typ" />
      <element name="c" type="t:typ" />
    </choice>
  </complexType>
</element>

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念