[英]How to reorder node elements such that they match an xsd:sequence order?
[英]How to allow elements in any order by using xsd:sequence?
我有一个带有以下代码的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>
我想使用xsd:sequence
但想以任何顺序接受元素。 我可以为此进行Java代码更改。 我正在使用JAXB来解组XML。
尝试了xsd:all
,但是我不想更改客户使用的XSD。
尝试了
xsd:all
,但是我不想更改客户使用的XSD。
这根本是错误的。 当前的XSD使用xsd:sequence
,它显式约束要排序的元素。 如果您希望顺序不再重要,那么可以通过将xsd:sequence
更改为xsd:all
来更改XSD以使其如此。 通过XSD说一件事(顺序很重要),而通过代码做点不同(顺序无关紧要)是一个非常糟糕的主意。
您的首要任务应该是维护XSD中表达的现有合同。 如果不可能,请以保持向后兼容性的方式进行更新。 如果这是不可能的,不建议使用老接口和不兼容的接口提供了充足的过渡时间。
以任何与其关联的XSD相矛盾的方式更改已发布接口的实现,甚至都不应该考虑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.