在 xsd:all 中具有 xsd:sequence 行为的替代方法是什么? [英] What is the alternative to have xsd:sequence behavior inside a xsd:all?

查看:35
本文介绍了在 xsd:all 中具有 xsd:sequence 行为的替代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白我应该如何定义我的复杂类型.

I don't understand how I should define my complex type.

今天我有这个:

<xsd:element name="batch_requests_callbacks">
    <xsd:complexType>
      <xsd:sequence>
            <xsd:element ref="document_id" minOccurs="1" maxOccurs="1"/>
            <xsd:choice minOccurs="0" maxOccurs="1">
              <xsd:element ref="filename"/>
              <xsd:element ref="error"/>
            </xsd:choice>
            <xsd:element ref="author" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="version" default="1.0"/>
    </xsd:complexType>
</xsd:element>

但是,xsd:sequence 中标签的顺序很重要,我不希望出现这种行为.

But then, the tag's order inside the xsd:sequence is important and I don't want that behavior.

如果我使用 xsd:all 我没有标签顺序但我不能将 maxOccurs 设置为 unbounded more 我不能使用 xsd:choicexsd:all

If I use xsd:all I don't have the tag order but I cannot set maxOccurs to unbounded more over I cannot use xsd:choice inside a xsd:all

我有哪些选择?

推荐答案

您可以使用 代替您的 xsd:sequence 以模拟无序元素验证.这绕过了 xsd:all 的限制.

You can use <xsd:choice minOccurs="0" maxOccurs="unbounded"> instead of your xsd:sequence in order to emulate non-ordered element validation. This circumvents the limitations of xsd:all.

这篇关于在 xsd:all 中具有 xsd:sequence 行为的替代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆