XSD序列显示为模棱两可 [英] XSD sequence shows as ambiguous

查看:134
本文介绍了XSD序列显示为模棱两可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从RELAX NG模式转换而来的XSD,但我尝试修复了一些错误.我遇到的最大问题是

I have an XSD which was transformed from a RELAX NG schema with a few errors I am trying to fix. The big issue I have it with the following

  <xs:element name="list">
    <xs:complexType>
      <xs:sequence>
        <xs:choice>
          <xs:sequence>
            <xs:element minOccurs="0" ref="preamble"/>
            <xs:element minOccurs="0" ref="title"/>
          </xs:sequence>
          <xs:sequence>
            <xs:element minOccurs="0" ref="title"/>
            <xs:element minOccurs="0" ref="preamble"/>
          </xs:sequence>
        </xs:choice>
        <xs:group maxOccurs="unbounded" ref="block-selectionListItem"/>
      </xs:sequence>
      <xs:attributeGroup ref="attlist-selectionList"/>
    </xs:complexType>
  </xs:element>

如您所见,xs:choice块允许您在两个xs:sequence块之间进行选择.似乎有道理,除了Visual Studio在第二个<xs:element minOccurs="0" ref="title/>元素上抛出以下警告之外,该元素将所有内容丢弃:

As you can see the xs:choice block allows you to pick between two xs:sequence blocks. Seems to make sense except that Visual Studio gives the following warning on the second <xs:element minOccurs="0" ref="title/> element which is throwing everything off:

元素"title"的多个定义导致内容模型变得模棱两可.必须形成一个内容模型,以便在验证元素信息项序列期间,可以唯一地确定直接,间接或隐式包含在其中的粒子,以此依次尝试验证序列中的每个项,而不必检查粒子的内容或属性.该项目,并且在序列的其余部分中没有有关该项目的任何信息.

Multiple definition of element 'title' causes the content model to become ambiguous. A content model must be formed such that during validation of an element information item sequence, the particle contained directly, indirectly or implicitly therein with which to attempt to validate each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

因为您只能选择一个,所以我看不出这是如何模棱两可的.任何帮助将不胜感激!

Because you can only choose one I do not see how this is ambiguous. Any help would be greatly appreciated!

答案:

正如下面的答案所指出的,我并没有考虑所有可能性.所以这就是我要做的:

As was pointed out in the answer below I was not accounting for all possibilities. So here is what I had to do:

  <xs:element name="list">
    <xs:complexType>
      <xs:sequence>
        <xs:group minOccurs ="0" maxOccurs="1" ref ="list-titlePreambleChoice"/>
        <xs:group maxOccurs="unbounded" ref="block-basicListItem"/>
      </xs:sequence>
      <xs:attributeGroup ref="attlist-basicList"/>
    </xs:complexType>
  </xs:element>

这解决了我所有的问题.谢谢!

This solved all my issues. Thanks!

推荐答案

由于minOccurs="0",因此模棱两可.如果验证程序找到了preamble元素,是第一个选择的第一个元素,还是第二个选择的第二个元素,并且缺少title元素?

It's ambiguous because of the minOccurs="0". If the validator finds a preamble element, is it the first element of the first choice, or is it the second element of the second choice and the title element is missing?

这篇关于XSD序列显示为模棱两可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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