XSD 不允许我在所有指标内有无界 [英] XSD doesn't allow me to have unbounded inside all indicator

查看:9
本文介绍了XSD 不允许我在所有指标内有无界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使 var1 中的变量无序列表出现两次,而 var2 出现无限次(我的项目中的用例不同).该元素不允许我使用 maxOccurs.

I'm trying to make unordered list of variables in var1 occurs twice and var2 occurs infinite times (Use case in my project is different). The element does not allow me to use maxOccurs.

对于我正在尝试做的事情有什么解决方法吗?

Is there any work around for what I'm trying to do?

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="testcomment">
    <xs:complexType>
      <xs:all>
        <xs:element name="var1" type="xs:string" maxOccurs="2" />
        <xs:element name="var2" type="xs:integer" maxOccurs="unbounded" />
      </xs:all>
    </xs:complexType>
  </xs:element>
</xs:schema>

推荐答案

您尝试执行的操作听起来像是列表中元素的类型在没有预读的情况下可能是模棱两可的,在这种情况下无法解决XSD 因为它可以描述的语言类别.

What you're trying to do sounds like the type of an element in your list might be ambiguous without reading-ahead, in which case there's no work around in XSD because of the classes of languages it can describe.

您能否发布 XSD 的相关部分?

Can you post up a the relevant part of your XSD?

更新:不,你不能用 XSD 做到这一点.例如,这里.此约束有一个名称 - UPA 或唯一粒子属性约束.这完全与歧义有关,Microsoft 网站很好地解释了为什么存在 这里.

Update: No, you can't do that with XSD. The rules about what you can put in an <xs:all> element are listed for example here. This constraint has a name - the UPA, or Unique Particle Attribution constraint. It's all to do with ambiguity and the Microsoft website has a good explanation of why is exists here.

您可以更改文档布局以消除对此类声明的需求,或者寻找更具表现力的模式语言,例如 放松NG.

You can either change your document layout to remove the need for this kind of declaration, or look to a more expressive schema language like RelaxNG.

这篇关于XSD 不允许我在所有指标内有无界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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