DTD-> XSD 转换:两个元素的混合列表,其中一个受约束
我试图在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用序列,如下所示:
替代文本http://www.freeimagehosting.net/uploads/29c07bafa2。 .png
Use sequences, like this:
alt text http://www.freeimagehosting.net/uploads/29c07bafa2.png