复杂类型的 XML 模式包含 <xs:all>和<xs:any>? [英] XML Schema with complext type containing <xs:all> and <xs:any>?
本文介绍了复杂类型的 XML 模式包含 <xs:all>和<xs:any>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想定义一个复杂类型,其中包含可能存在也可能不存在的元素,并且还允许其他未定义的元素,所以我得到了这样的东西:
I want to define a complex type that contains elements that may or may not exist, and also allows for additional undefined elements so I've got something like this:
<xs:complexType name="MyType">
<xs:sequence>
<xs:element name="A" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="B" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="C" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:any minOccurs="0" processContents="skip"/>
</xs:sequence>
</xs:complexType>
我不想使用
强制顺序,所以我想将
更改为 <;xs:all>
但随后
是不允许的.有没有办法做到这一点?
I don't want to force the order using <xs:sequence>
so I want to change the <xs:sequence>
to <xs:all>
but then <xs:any>
isn't allowed. Is there some way to accomplish this?
推荐答案
要允许任何顺序,请使用:
To allow any order, use this:
<xs:complexType name="MyType">
<xs:all minOccurs="1" maxOccurs="1">
<xs:element name="A" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="B" type="xs:float" minOccurs="0" maxOccurs="1" />
<xs:element name="C" type="xs:float" minOccurs="0" maxOccurs="1" />
</xs:all>
</xs:complexType>
但是,您不能在
中包含
.
也不能将它们都包含在一种类型中,直接或作为扩展.
But then, you can't have an <any>
inside an <all>
.
Nor can you have them both inside one type, either directly or as an extension.
这篇关于复杂类型的 XML 模式包含 <xs:all>和<xs:any>?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文