如何创建一个 complexType,其中元素可以按任何顺序排列,并且一个元素必须至少出现一次 [英] How to create a complexType where elements can be in any order, and one element must occur at least once
本文介绍了如何创建一个 complexType,其中元素可以按任何顺序排列,并且一个元素必须至少出现一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个复杂的类型,例如:
I have a complex type like:
<xs:complexType name="blocks">
<xs:sequence>
<xs:element name="BlockA" type="blockA" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="BlockB" type="blockB" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Use" type="xs:boolean" use="required" /></xs:complexType>
但它不是我想要的配置.
but it is not configured how I would like.
我想要这样
- 元素BlockA"和BlockB"可以是任意顺序
- BlockA 必须至少发生 1 次.
- BlockB 可以出现 0 次或多次.
XSD 顺序指示符顺序"和选择"似乎没有提供此类选项.
The XSD order indicators 'sequence' and 'choice' don't seem to provide such options.
有没有办法实现我的目标?
Is there a way to achieve what I am looking for?
推荐答案
如果你需要在 XSD 1.0 中这样做我相信它可以表示为
If you need to do this in XSD 1.0 I believe it can be expressed as
sequence
element name=BlockB min=0 max=unbounded
element name=BlockA min=1 max=1
choice min=0 max=unbounded
element name=BlockA min=1 max=1
element name=BlockB min=1 max=1
这篇关于如何创建一个 complexType,其中元素可以按任何顺序排列,并且一个元素必须至少出现一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文