DTD-> XSD 转换:两个元素的混合列表,其中一个受约束

发布于 2024-07-26 19:29:26 字数 1193 浏览 10 评论 0原文

我试图在 XSD 中表示以下 DTD 片段:-

(A | B)* | (A | C)* | (A | D)* | ...

即任意数量的 As 和任意数量的 B、C、D 的一个的混合列表,...

CastorConverter 吐出:-

              <choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:B" />
                    </choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:C" />
                    </choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:D" />
                    </choice>
              </choice>

但这给了我一个解析器错误。 使用 Visual Studio 进行调查会出现以下警告:-

“元素“A”的多重定义会导致内容模型变得不明确。必须形成内容模型,以便在验证元素信息项序列期间,直接、间接包含的粒子或隐式地其中试图依次验证序列中的每个项目可以被唯一地确定,而无需检查该项目的内容或属性,并且无需关于序列的其余部分中的项目的任何信息。”

问题似乎是,如果解析器遇到“A”,则需要“前瞻”序列的其余部分,以确定要验证的选择。

有没有其他方法可以在 XSD 中表示这个序列?

I'm trying to represent the following DTD fragment in XSD:-

(A | B)* | (A | C)* | (A | D)* | ...

i.e. a mixed list of any number of As and any number of one of B, C, D, ...

CastorConverter spits out:-

              <choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:B" />
                    </choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:C" />
                    </choice>
                    <choice minOccurs="0" maxOccurs="unbounded">
                          <element ref="tns:A" />
                          <element ref="tns:D" />
                    </choice>
              </choice>

but this gives me a parser error. Investigating with visual studio brings up the following warning:-

"Multiple definition of element 'A' 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."

The problem appears to be that if the parser encounters an "A" will need to "look-ahead" to the rest of the sequence in order to determine which choice to validate against.

Is there another way I can represent this sequence in XSD?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挥剑断情 2024-08-02 19:29:27

使用序列,如下所示:

<sequence minOccurs="0">
  <element minOccurs="0" maxOccurs="unbounded" ref="tns:A" />
  <choice>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:B" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:B" />
      </sequence>
    </sequence>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:C" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:C" />
      </sequence>
    </sequence>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:D" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:D" />
      </sequence>
    </sequence>
  </choice>
</sequence>

替代文本http://www.freeimagehosting.net/uploads/29c07bafa2。 .png

Use sequences, like this:

<sequence minOccurs="0">
  <element minOccurs="0" maxOccurs="unbounded" ref="tns:A" />
  <choice>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:B" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:B" />
      </sequence>
    </sequence>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:C" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:C" />
      </sequence>
    </sequence>
    <sequence>
      <element minOccurs="1" maxOccurs="unbounded" ref="tns:D" />
      <sequence minOccurs="0" maxOccurs="unbounded">
        <element maxOccurs="unbounded" ref="tns:A" />
        <element minOccurs="0" maxOccurs="unbounded" ref="tns:D" />
      </sequence>
    </sequence>
  </choice>
</sequence>

alt text http://www.freeimagehosting.net/uploads/29c07bafa2.png

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文