简体   繁体   English

如何通过使用xsd:sequence允许任何顺序的元素?

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

Don't change the semantics of xsd:sequence 不要更改xsd:sequence的语义

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说一件事(顺序很重要),而通过代码做点不同(顺序无关紧要)是一个非常糟糕的主意。

Basic Responsible Versioning 基本负责版本

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.

相关问题 如何对节点元素重新排序,使其与xsd:sequence顺序匹配? - How to reorder node elements such that they match an xsd:sequence order? XSD-任何(未知)元素的未绑定数目,但定义了序列中的最后一个元素 - XSD - unbound number of any (unkown) elements but last element in sequence is defined 扩展XSD以放置单个元素,而不是在XSD中使用xs:any - Extend XSD to put individual elements instead of using the xs:any in an XSD 如何使用Java解析xsd字符串以获取其元素? - How to parse xsd String to fetch its elements using java? 使用XSD中的元素“anyAttribute”和“any”将XML编组为Java - Marshalling XML to Java with elements “anyAttribute” and “any” in XSD 使用xsd:any用于可扩展模式 - using xsd:any for extensible schema 如何在XSD中指定重复元素 - How to specify repeated elements in XSD 如何使用 Java 和 XmlSchema Core 解析 XSD 并读取所有复杂元素及其子元素 - How to parse XSD and read all the complex elements and its child elements using the Java and XmlSchema Core 如何以相反的顺序打印斐波纳契序列而不使用循环 - How to print the fibonacci sequence in reverse order WITHOUT using a loop 如何允许我的复杂类型中的任何类型的元素排除导入模式中的类型/元素 - How to allow elements of any type in my complex type excluding the types/elements from imported schemas
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM