[英]How to allow elements in any order by using xsd:sequence?
I have an XSD with the below code: 我有一个带有以下代码的XSD:
<xsd:complexType name="SupplierProfileType">
<xsd:sequence>
<xsd:element name="Subscriber" type="BIS_SubscriberType"/>
<xsd:element name="BusinessApplicant" type="BusinessApplicantType"/>
<xsd:element name="AddOns" type="SupplierProfile_AddOnsType" minOccurs="0"/>
<xsd:element name="OutputType" type="BusinessProfile_OutputType"/>
<xsd:element name="Vendor" type="Business_VendorType" minOccurs="0"/>
<xsd:element name="Options" type="BISOptions3_OptionsType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
I want to use xsd:sequence
but want to accept the elements in any order. 我想使用
xsd:sequence
但想以任何顺序接受元素。 I am ok to make Java code changes for this. 我可以为此进行Java代码更改。 I am using JAXB for unmarshalling of the XML.
我正在使用JAXB来解组XML。
Tried xsd:all
, but I don't want to change the XSD as it is used by customers. 尝试了
xsd:all
,但是我不想更改客户使用的XSD。
Tried
xsd:all
, but I don't want to change the XSD as it is used by customers.尝试了
xsd:all
,但是我不想更改客户使用的XSD。
That's fundamentally wrong. 这根本是错误的。 Your current XSD uses
xsd:sequence
, which explicitly constrains elements to be ordered. 当前的XSD使用
xsd:sequence
,它显式约束要排序的元素。 If you want order to no longer be significant, then, change your XSD to say so via a change from xsd:sequence
to xsd:all
. 如果您希望顺序不再重要,那么可以通过将
xsd:sequence
更改为xsd:all
来更改XSD以使其如此。 Saying one thing via your XSD (order matters) and doing something different via your code (order doesn't matter) is a very bad idea. 通过XSD说一件事(顺序很重要),而通过代码做点不同(顺序无关紧要)是一个非常糟糕的主意。
Your first priority should be to maintain the existing contract expressed in the XSD. 您的首要任务应该是维护XSD中表达的现有合同。 If that's impossible, update in a way that preserves backward compatibility.
如果不可能,请以保持向后兼容性的方式进行更新。 If that's impossible, deprecate the old interface and provide ample transition time to the incompatible interface.
如果这是不可能的,不建议使用老接口和不兼容的接口提供了充足的过渡时间。
Changing implementation of a published interface in any way that contradicts its associated XSD should not even be a consideration. 以任何与其关联的XSD相矛盾的方式更改已发布接口的实现,甚至都不应该考虑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.