xsd:all: 元素 'Child2' 的值 'unbounded' 无效 [英] xsd:all: The value 'unbounded' for element 'Child2' is invalid

查看:27
本文介绍了xsd:all: 元素 'Child2' 的值 'unbounded' 无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误信息:

[错误] try.xsd:5:15: cos-all-limited.2: {max出现}'all' 模型组中的元素必须是 0 或 1.值 'unbounded'对于元素Child2"无效.

[Error] try.xsd:5:15: cos-all-limited.2: The {max occurs} of an element in an 'all' model group must be 0 or 1. The value 'unbounded' for element 'Child2' is invalid.

我有以下 XML 文档:

I have the following XML documents:

一个

<Parent>
       <Child1>value</Child1>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child4>value</Child4>
       <Child5>value</Child5>
</Parent>   

两个

<Parent>
       <Child5>value</Child5>
       <Child1>value</Child1>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child2>value</Child2>
       <Child3>value</Child3>
       <Child4>value</Child4>
</Parent>   

元素以任意顺序出现.所以我定义了这样的架构:

The elements appear in any order. So I defined the schema like this:

<xs:element name="Parent">
<xs:complexType>
    <xs:all>
      <xs:element name="Child1" type="xs:int"  minOccurs="0"/>
      <xs:element name="Child2" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Child3" type="xs:string"  minOccurs="0" maxOccurs="unbounded"/>
      <xs:element name="Child4" type="xs:string"  minOccurs="0"/>
      <xs:element name="Child5" type="xs:string"  minOccurs="0"/>
    </xs:all>
</xs:complexType>
</xs:element>

我面临两个问题:

  1. xs:all 不允许使用无界.
  2. 有没有办法定义Child2Child3 之间的关系.
  1. Unbounded is not allowed with xs:all.
  2. Is there any way to define a relationship between Child2 and Child3.

推荐答案

  1. 在 XSD 1.0 中,xsd:all 的子项不能重复.如果 Child2Child3 只能出现无限次,请改用 xs:sequence.理论上支持 parent 下的无序子节点可能会更好地匹配您的实际约束,但在实践中,强加一个顺序很少重要,并且通常在这种情况下会有所帮助.
  2. 是的,有多种方法可以定义 Child2Child3 之间的关系,但更具体的是,您必须指明您要定义的关系类型记住.
  1. In XSD 1.0, children of xsd:all cannot be repeated. If Child2 and Child3 only can occur an unbounded number of times, use xs:sequence instead. In theory supporting unordered children under parent may match your actual constraints slightly better, but in practice, imposing an order rarely matters and often helps such as in cases like this.
  2. Yes, there are ways to define a relationship between Child2 and Child3, but to be more specific than that, you'd have to indicate the sort of relationship you have in mind.

这篇关于xsd:all: 元素 'Child2' 的值 'unbounded' 无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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