[英]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.