<all><sequence><choice>和<group>在XSD的区别?

The difference between <all> <sequence> <choice> and <group> in XSD?

XML 架构中的 <all> <sequence> <choice> and <group> 有什么区别?

何时使用 xsd:allxsd:sequencexsd:choicexsd:group

  • 当所有子元素都必须存在时使用xsd:all,独立于 订单。
  • 当子元素必须存在时使用 xsd:sequence 出现限制和顺序很重要。
  • 当其中一个子元素必须存在时使用 xsd:choice
  • 使用xsd:group作为包装上述任何内容的方式以命名 并在 XSD.
  • 内的多个位置重复使用

请注意,除了子元素之外,出现约束还可以出现在 xsd:allxsd:sequencexsd:choice 上,以实现各种基数效果。